{"id":13735129,"url":"https://github.com/omniauth/omniauth-saml","last_synced_at":"2026-02-21T09:05:23.249Z","repository":{"id":2470830,"uuid":"3443382","full_name":"omniauth/omniauth-saml","owner":"omniauth","description":"A generic SAML strategy for OmniAuth","archived":false,"fork":false,"pushed_at":"2025-03-30T09:51:59.000Z","size":305,"stargazers_count":340,"open_issues_count":30,"forks_count":208,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-05-06T10:47:05.996Z","etag":null,"topics":["omniauth","saml"],"latest_commit_sha":null,"homepage":"https://github.com/omniauth/omniauth-saml","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omniauth.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-02-14T20:00:14.000Z","updated_at":"2025-03-30T09:51:58.000Z","dependencies_parsed_at":"2024-01-12T03:36:57.097Z","dependency_job_id":"f79ff3ce-ddbe-4ef6-8241-4f542481a749","html_url":"https://github.com/omniauth/omniauth-saml","commit_stats":{"total_commits":183,"total_committers":55,"mean_commits":3.327272727272727,"dds":0.8852459016393442,"last_synced_commit":"ca4d806a0a4e2a1fae18e1dbfd9536e611a46c81"},"previous_names":["practicallygreen/omniauth-saml"],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omniauth%2Fomniauth-saml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omniauth%2Fomniauth-saml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omniauth%2Fomniauth-saml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omniauth%2Fomniauth-saml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omniauth","download_url":"https://codeload.github.com/omniauth/omniauth-saml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253346994,"owners_count":21894275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["omniauth","saml"],"created_at":"2024-08-03T03:01:03.276Z","updated_at":"2026-02-21T09:05:23.243Z","avatar_url":"https://github.com/omniauth.png","language":"Ruby","funding_links":[],"categories":["Programming Language Libraries","Ruby"],"sub_categories":["Ruby"],"readme":"# OmniAuth SAML\n\n[![Gem Version](http://img.shields.io/gem/v/omniauth-saml.svg)][gem]\n[![Ruby](https://github.com/omniauth/omniauth-saml/actions/workflows/ruby.yml/badge.svg)](https://github.com/omniauth/omniauth-saml/actions/workflows/ruby.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/749e17b553ea944522c1/maintainability)][codeclimate]\n[![Coverage Status](http://img.shields.io/coveralls/omniauth/omniauth-saml.svg)][coveralls]\n\n[gem]: https://rubygems.org/gems/omniauth-saml\n[codeclimate]: https://codeclimate.com/github/omniauth/omniauth-saml/maintainability\n[coveralls]: https://coveralls.io/r/omniauth/omniauth-saml\n\nA generic SAML strategy for OmniAuth available under the [MIT License](LICENSE.md)\n\nhttps://github.com/omniauth/omniauth-saml\n\n## Requirements\n\n* [OmniAuth](http://www.omniauth.org/) 2.1+\n* Ruby 3.1.x+\n\n## Versioning\n\nWe tag and release gems according to the [Semantic Versioning](http://semver.org/) principle. In addition to the guidelines of Semantic Versioning, we follow a further guideline that otherwise backwards-compatible dependency upgrades for security reasons should generally be cause for a MINOR version upgrade as opposed to a PATCH version upgrade. Backwards-incompatible dependency upgrades for security reasons should still result in a MAJOR version upgrade for this library.\n\n## Usage\n\nUse the SAML strategy as a middleware in your application:\n\n```ruby\nrequire 'omniauth'\nuse OmniAuth::Strategies::SAML,\n  :assertion_consumer_service_url     =\u003e \"consumer_service_url\",\n  :sp_entity_id                       =\u003e \"sp_entity_id\",\n  :idp_sso_service_url                =\u003e \"idp_sso_service_url\",\n  :idp_sso_service_url_runtime_params =\u003e {:original_request_param =\u003e :mapped_idp_param},\n  :idp_cert                           =\u003e \"-----BEGIN CERTIFICATE-----\\n...-----END CERTIFICATE-----\",\n  :idp_cert_multi                     =\u003e {\n                                           :signing =\u003e [\"-----BEGIN CERTIFICATE-----\\n...-----END CERTIFICATE-----\", \"-----BEGIN CERTIFICATE-----\\n...-----END CERTIFICATE-----\", ...],\n                                           :encryption =\u003e []\n                                         },\n  :idp_cert_fingerprint               =\u003e \"E7:91:B2:E1:...\",\n  :name_identifier_format             =\u003e \"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress\"\n```\n\nor in your Rails application:\n\nin `Gemfile`:\n\n```ruby\ngem 'omniauth-saml'\n```\n\nand in `config/initializers/omniauth.rb`:\n\n```ruby\nRails.application.config.middleware.use OmniAuth::Builder do\n  provider :saml,\n    :assertion_consumer_service_url     =\u003e \"consumer_service_url\",\n    :sp_entity_id                       =\u003e \"rails-application\",\n    :idp_sso_service_url                =\u003e \"idp_sso_service_url\",\n    :idp_sso_service_url_runtime_params =\u003e {:original_request_param =\u003e :mapped_idp_param},\n    :idp_cert                           =\u003e \"-----BEGIN CERTIFICATE-----\\n...-----END CERTIFICATE-----\",\n    :idp_cert_multi                     =\u003e {\n                                             :signing =\u003e [\"-----BEGIN CERTIFICATE-----\\n...-----END CERTIFICATE-----\", \"-----BEGIN CERTIFICATE-----\\n...-----END CERTIFICATE-----\", ...],\n                                             :encryption =\u003e []\n                                           },\n    :idp_cert_fingerprint               =\u003e \"E7:91:B2:E1:...\",\n    :name_identifier_format             =\u003e \"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress\"\nend\n```\n\nFor IdP-initiated SSO, users should directly access the IdP SSO service URL. Set the `href` of your application's login link to the value of `idp_sso_service_url`. For SP-initiated SSO, link to `/auth/saml`.\n\nA `OneLogin::RubySaml::Response` object is added to the `env['omniauth.auth']` extra attribute, so we can use it in the controller via `env['omniauth.auth'].extra.response_object`\n\n## SP Metadata\n\nThe service provider metadata used to ease configuration of the SAML SP in the IdP can be retrieved from `http://example.com/auth/saml/metadata`. Send this URL to the administrator of the IdP.\n\nNote that when [integrating with Devise](#devise-integration), the URL path will be scoped according to the name of the Devise resource.  For example, if the app's user model calls `devise_for :users`, the metadata URL will be `http://example.com/users/auth/saml/metadata`.\n\n## Options\n\n* `:assertion_consumer_service_url` - The URL at which the SAML assertion should be\n  received. If not provided, defaults to the OmniAuth callback URL (typically\n  `http://example.com/auth/saml/callback`). Optional.\n\n* `:sp_entity_id` - The name of your application. Some identity providers might need this\n  to establish the identity of the service provider requesting the login. **Required**.\n\n* `:idp_sso_service_url` - The URL to which the authentication request should be sent.\n  This would be on the identity provider. **Required**.\n\n* `:idp_slo_service_url` - The URL to which the single logout request and response should\n  be sent. This would be on the identity provider. Optional.\n\n* `:idp_slo_session_destroy` - A proc that accepts up to two parameters (the rack environment, and the session),\n  and performs whatever tasks are necessary to log out the current user from your application.\n  See the example listed under \"Single Logout.\" Defaults to calling `#clear` on the session. Optional.\n\n* `:slo_default_relay_state` - The value to use as default `RelayState` for single log outs. The\n  value can be a string, or a `Proc` (or other object responding to `call`). The `request`\n  instance will be passed to this callable if it has an arity of 1. If the value is a string,\n  the string will be returned, when the `RelayState` is called.\n  The value is assumed to be safe and is not validated by `:slo_relay_state_validator`.\n  Optional.\n\n* `:slo_enabled` - Enables or disables Single Logout (SLO). Set to `false` to disable SLO. Defaults to `true`. Optional.\n\n* `:slo_relay_state_validator` - A callable used to validate any `RelayState` before performing the redirect\n  in Single Logout flows. The callable receives the RelayState value and the current Rack request.\n  If unset, the default validator is used. The default validator allows only relative paths beginning\n  with `/` and rejects absolute URLs, invalid URIs, protocol-relative URLs, and other schemes.\n  If the given `RelayState` is considered invalid then the `slo_default_relay_state` value is used for the SLO redirect.\n  Optional.\n\n* `:idp_sso_service_url_runtime_params` - A dynamic mapping of request params that exist\n  during the request phase of OmniAuth that should to be sent to the IdP after a specific\n  mapping. So for example, a param `original_request_param` with value `original_param_value`,\n  could be sent to the IdP on the login request as `mapped_idp_param` with value\n  `original_param_value`. Optional.\n\n* `:idp_cert` - The identity provider's certificate in PEM format. Takes precedence\n  over the fingerprint option below. This option or `:idp_cert_multi` or `:idp_cert_fingerprint` must\n  be present.\n\n* `:idp_cert_multi` - Multiple identity provider certificates in PEM format. Takes precedence\nover the fingerprint option below. This option `:idp_cert` or `:idp_cert_fingerprint` must\nbe present.\n\n* `:idp_cert_fingerprint` - The SHA1 fingerprint of the certificate, e.g.\n  \"90:CC:16:F0:8D:...\". This is provided from the identity provider when setting up\n  the relationship. This option or `:idp_cert` or `:idp_cert_multi` MUST be present.\n\n* `:name_identifier_format` - Used during SP-initiated SSO. Describes the format of\n  the username required by this application. If you need the email address, use\n  \"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress\". See\n  http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf section 8.3 for\n  other options. Note that the identity provider might not support all options.\n  If not specified, the IdP is free to choose the name identifier format used\n  in the response. Optional.\n\n* `:request_attributes` - Used to build the metadata file to inform the IdP to send certain attributes\n  along with the SAMLResponse messages. Defaults to requesting `name`, `first_name`, `last_name` and `email`\n  attributes. See the `OneLogin::RubySaml::AttributeService` class in the [Ruby SAML gem](https://github.com/onelogin/ruby-saml) for the available options for each attribute. Set to `{}` to disable this from metadata.\n\n* `:attribute_service_name` - Name for the attribute service. Defaults to `Required attributes`.\n\n* `:attribute_statements` - Used to map Attribute Names in a SAMLResponse to\n  entries in the OmniAuth [info hash](https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema#schema-10-and-later).\n  For example, if your SAMLResponse contains an Attribute called 'EmailAddress',\n  specify `{:email =\u003e ['EmailAddress']}` to map the Attribute to the\n  corresponding key in the info hash.  URI-named Attributes are also supported, e.g.\n  `{:email =\u003e ['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress']}`.\n  *Note*: All attributes can also be found in an array under `auth_hash[:extra][:raw_info]`,\n  so this setting should only be used to map attributes that are part of the OmniAuth info hash schema.\n\n* `:uid_attribute` - Attribute that uniquely identifies the user. If unset, the name identifier returned by the IdP is used.\n\n* See the `OneLogin::RubySaml::Settings` class in the [Ruby SAML gem](https://github.com/onelogin/ruby-saml) for additional supported options.\n\n## IdP Metadata\n\nYou can use the `OneLogin::RubySaml::IdpMetadataParser` to configure some options:\n\n```ruby\nrequire 'omniauth'\nidp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new\nidp_metadata = idp_metadata_parser.parse_remote_to_hash(\"http://idp.example.com/saml/metadata\")\n\n# or, if you have the metadata in a String:\n# idp_metadata = idp_metadata_parser.parse_to_hash(idp_metadata_xml)\n\nuse OmniAuth::Strategies::SAML,\n  idp_metadata.merge(\n    :assertion_consumer_service_url =\u003e \"consumer_service_url\",\n    :sp_entity_id                   =\u003e \"sp_entity_id\"\n  )\n```\n\nSee the [Ruby SAML gem's README](https://github.com/onelogin/ruby-saml#metadata-based-configuration) for more details.\n\n## Devise Integration\n\nStraightforward integration with [Devise](https://github.com/plataformatec/devise), the widely-used authentication solution for Rails.\n\nIn `config/initializers/devise.rb`:\n\n```ruby\nDevise.setup do |config|\n  config.omniauth :saml,\n    idp_cert_fingerprint: 'fingerprint',\n    idp_sso_service_url: 'idp_sso_service_url'\nend\n```\n\nThen follow Devise's general [OmniAuth tutorial](https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview), replacing references to `facebook` with `saml`.\n\n## Single Logout\n\nSingle Logout can be Service Provider initiated or Identity Provider initiated.\n\nFor SP initiated logout, the `idp_slo_service_url` option must be set to the logout url on the IdP,\nand users directed to `user_saml_omniauth_authorize_path + '/spslo'` after logging out locally. For\nIdP initiated logout, logout requests from the IdP should go to `/auth/saml/slo` (this can be\nadvertised in metadata by setting the `single_logout_service_url` config option). If you wish to\ndisable Single Logout entirely (both SP and IdP initiated), set `:slo_enabled =\u003e false`; the `/auth/saml/slo`\nand `/auth/saml/spslo` endpoints will then respond with HTTP 501 Not Implemented.\n\nWhen using Devise as an authentication solution, the SP initiated flow can be integrated\nin the `SessionsController#destroy` action.\n\nFor this to work it is important to preserve the `saml_uid` and `saml_session_index` value before Devise\nclears the session and redirect to the `/spslo` sub-path to initiate the single logout.\n\nExample `destroy` action in `sessions_controller.rb`:\n\n```ruby\nclass SessionsController \u003c Devise::SessionsController\n  # ...\n\n  def destroy\n    # Preserve the saml_uid and saml_session_index in the session\n    saml_uid = session['saml_uid']\n    saml_session_index = session['saml_session_index']\n    super do\n      session['saml_uid'] = saml_uid\n      session['saml_session_index'] = saml_session_index\n    end\n  end\n\n  # ...\n\n  def after_sign_out_path_for(_)\n    if session['saml_uid'] \u0026\u0026 session['saml_session_index'] \u0026\u0026 SAML_SETTINGS.idp_slo_service_url\n      user_saml_omniauth_authorize_path + \"/spslo\"\n    else\n      super\n    end\n  end\nend\n```\n\nBy default, omniauth-saml attempts to log the current user out of your application by clearing the session.\nThis may not be enough for some authentication solutions (e.g. [Clearance](https://github.com/thoughtbot/clearance/)).\nInstead, you may set the `:idp_slo_session_destroy` option to a proc that performs the necessary logout tasks.\n\nExample `:idp_slo_session_destroy` setting for Clearance compatibility:\n\n```ruby\nRails.application.config.middleware.use OmniAuth::Builder do\n  provider :saml, idp_slo_session_destroy: proc { |env, _session| env[:clearance].sign_out }, ...\nend\n```\n\n## Authors\n\nAuthored by [Rajiv Aaron Manglani](http://www.rajivmanglani.com/), Raecoo Cao, Todd W Saxton, Ryan Wilcox, Steven Anderson, Nikos Dimitrakopoulos, Rudolf Vriend and [Bruno Pedro](http://brunopedro.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomniauth%2Fomniauth-saml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomniauth%2Fomniauth-saml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomniauth%2Fomniauth-saml/lists"}