A summary of data about the Ruby ecosystem.

https://github.com/omniauth/omniauth-saml

A generic SAML strategy for OmniAuth
https://github.com/omniauth/omniauth-saml

Keywords

omniauth saml

Keywords from Contributors

activerecord activejob mvc oauth2 rubygems rubocop static-code-analysis code-formatter money exchange-rate

Last synced: about 22 hours ago
JSON representation

Repository metadata

A generic SAML strategy for OmniAuth

README.md

OmniAuth SAML

Gem Version
Ruby
Maintainability
Coverage Status

A generic SAML strategy for OmniAuth available under the MIT License

https://github.com/omniauth/omniauth-saml

Requirements

Versioning

We tag and release gems according to the Semantic Versioning 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.

Usage

Use the SAML strategy as a middleware in your application:

require 'omniauth'
use OmniAuth::Strategies::SAML,
  :assertion_consumer_service_url     => "consumer_service_url",
  :sp_entity_id                       => "sp_entity_id",
  :idp_sso_service_url                => "idp_sso_service_url",
  :idp_sso_service_url_runtime_params => {:original_request_param => :mapped_idp_param},
  :idp_cert                           => "-----BEGIN CERTIFICATE-----\n...-----END CERTIFICATE-----",
  :idp_cert_multi                     => {
                                           :signing => ["-----BEGIN CERTIFICATE-----\n...-----END CERTIFICATE-----", "-----BEGIN CERTIFICATE-----\n...-----END CERTIFICATE-----", ...],
                                           :encryption => []
                                         },
  :idp_cert_fingerprint               => "E7:91:B2:E1:...",
  :name_identifier_format             => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"

or in your Rails application:

in Gemfile:

gem 'omniauth-saml'

and in config/initializers/omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :saml,
    :assertion_consumer_service_url     => "consumer_service_url",
    :sp_entity_id                       => "rails-application",
    :idp_sso_service_url                => "idp_sso_service_url",
    :idp_sso_service_url_runtime_params => {:original_request_param => :mapped_idp_param},
    :idp_cert                           => "-----BEGIN CERTIFICATE-----\n...-----END CERTIFICATE-----",
    :idp_cert_multi                     => {
                                             :signing => ["-----BEGIN CERTIFICATE-----\n...-----END CERTIFICATE-----", "-----BEGIN CERTIFICATE-----\n...-----END CERTIFICATE-----", ...],
                                             :encryption => []
                                           },
    :idp_cert_fingerprint               => "E7:91:B2:E1:...",
    :name_identifier_format             => "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
end

For 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.

A 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

SP Metadata

The 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.

Note that when integrating with Devise, 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.

Options

  • :assertion_consumer_service_url - The URL at which the SAML assertion should be
    received. If not provided, defaults to the OmniAuth callback URL (typically
    http://example.com/auth/saml/callback). Optional.

  • :sp_entity_id - The name of your application. Some identity providers might need this
    to establish the identity of the service provider requesting the login. Required.

  • :idp_sso_service_url - The URL to which the authentication request should be sent.
    This would be on the identity provider. Required.

  • :idp_slo_service_url - The URL to which the single logout request and response should
    be sent. This would be on the identity provider. Optional.

  • :idp_slo_session_destroy - A proc that accepts up to two parameters (the rack environment, and the session),
    and performs whatever tasks are necessary to log out the current user from your application.
    See the example listed under "Single Logout." Defaults to calling #clear on the session. Optional.

  • :slo_default_relay_state - The value to use as default RelayState for single log outs. The
    value can be a string, or a Proc (or other object responding to call). The request
    instance will be passed to this callable if it has an arity of 1. If the value is a string,
    the string will be returned, when the RelayState is called.
    The value is assumed to be safe and is not validated by :slo_relay_state_validator.
    Optional.

  • :slo_enabled - Enables or disables Single Logout (SLO). Set to false to disable SLO. Defaults to true. Optional.

  • :slo_relay_state_validator - A callable used to validate any RelayState before performing the redirect
    in Single Logout flows. The callable receives the RelayState value and the current Rack request.
    If unset, the default validator is used. The default validator allows only relative paths beginning
    with / and rejects absolute URLs, invalid URIs, protocol-relative URLs, and other schemes.
    If the given RelayState is considered invalid then the slo_default_relay_state value is used for the SLO redirect.
    Optional.

  • :idp_sso_service_url_runtime_params - A dynamic mapping of request params that exist
    during the request phase of OmniAuth that should to be sent to the IdP after a specific
    mapping. So for example, a param original_request_param with value original_param_value,
    could be sent to the IdP on the login request as mapped_idp_param with value
    original_param_value. Optional.

  • :idp_cert - The identity provider's certificate in PEM format. Takes precedence
    over the fingerprint option below. This option or :idp_cert_multi or :idp_cert_fingerprint must
    be present.

  • :idp_cert_multi - Multiple identity provider certificates in PEM format. Takes precedence
    over the fingerprint option below. This option :idp_cert or :idp_cert_fingerprint must
    be present.

  • :idp_cert_fingerprint - The SHA1 fingerprint of the certificate, e.g.
    "90:CC:16:F0:8D:...". This is provided from the identity provider when setting up
    the relationship. This option or :idp_cert or :idp_cert_multi MUST be present.

  • :name_identifier_format - Used during SP-initiated SSO. Describes the format of
    the username required by this application. If you need the email address, use
    "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress". See
    http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf section 8.3 for
    other options. Note that the identity provider might not support all options.
    If not specified, the IdP is free to choose the name identifier format used
    in the response. Optional.

  • :request_attributes - Used to build the metadata file to inform the IdP to send certain attributes
    along with the SAMLResponse messages. Defaults to requesting name, first_name, last_name and email
    attributes. See the OneLogin::RubySaml::AttributeService class in the Ruby SAML gem for the available options for each attribute. Set to {} to disable this from metadata.

  • :attribute_service_name - Name for the attribute service. Defaults to Required attributes.

  • :attribute_statements - Used to map Attribute Names in a SAMLResponse to
    entries in the OmniAuth info hash.
    For example, if your SAMLResponse contains an Attribute called 'EmailAddress',
    specify {:email => ['EmailAddress']} to map the Attribute to the
    corresponding key in the info hash. URI-named Attributes are also supported, e.g.
    {:email => ['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress']}.
    Note: All attributes can also be found in an array under auth_hash[:extra][:raw_info],
    so this setting should only be used to map attributes that are part of the OmniAuth info hash schema.

  • :uid_attribute - Attribute that uniquely identifies the user. If unset, the name identifier returned by the IdP is used.

  • See the OneLogin::RubySaml::Settings class in the Ruby SAML gem for additional supported options.

IdP Metadata

You can use the OneLogin::RubySaml::IdpMetadataParser to configure some options:

require 'omniauth'
idp_metadata_parser = OneLogin::RubySaml::IdpMetadataParser.new
idp_metadata = idp_metadata_parser.parse_remote_to_hash("http://idp.example.com/saml/metadata")

# or, if you have the metadata in a String:
# idp_metadata = idp_metadata_parser.parse_to_hash(idp_metadata_xml)

use OmniAuth::Strategies::SAML,
  idp_metadata.merge(
    :assertion_consumer_service_url => "consumer_service_url",
    :sp_entity_id                   => "sp_entity_id"
  )

See the Ruby SAML gem's README for more details.

Devise Integration

Straightforward integration with Devise, the widely-used authentication solution for Rails.

In config/initializers/devise.rb:

Devise.setup do |config|
  config.omniauth :saml,
    idp_cert_fingerprint: 'fingerprint',
    idp_sso_service_url: 'idp_sso_service_url'
end

Then follow Devise's general OmniAuth tutorial, replacing references to facebook with saml.

Single Logout

Single Logout can be Service Provider initiated or Identity Provider initiated.

For SP initiated logout, the idp_slo_service_url option must be set to the logout url on the IdP,
and users directed to user_saml_omniauth_authorize_path + '/spslo' after logging out locally. For
IdP initiated logout, logout requests from the IdP should go to /auth/saml/slo (this can be
advertised in metadata by setting the single_logout_service_url config option). If you wish to
disable Single Logout entirely (both SP and IdP initiated), set :slo_enabled => false; the /auth/saml/slo
and /auth/saml/spslo endpoints will then respond with HTTP 501 Not Implemented.

When using Devise as an authentication solution, the SP initiated flow can be integrated
in the SessionsController#destroy action.

For this to work it is important to preserve the saml_uid and saml_session_index value before Devise
clears the session and redirect to the /spslo sub-path to initiate the single logout.

Example destroy action in sessions_controller.rb:

class SessionsController < Devise::SessionsController
  # ...

  def destroy
    # Preserve the saml_uid and saml_session_index in the session
    saml_uid = session['saml_uid']
    saml_session_index = session['saml_session_index']
    super do
      session['saml_uid'] = saml_uid
      session['saml_session_index'] = saml_session_index
    end
  end

  # ...

  def after_sign_out_path_for(_)
    if session['saml_uid'] && session['saml_session_index'] && SAML_SETTINGS.idp_slo_service_url
      user_saml_omniauth_authorize_path + "/spslo"
    else
      super
    end
  end
end

By default, omniauth-saml attempts to log the current user out of your application by clearing the session.
This may not be enough for some authentication solutions (e.g. Clearance).
Instead, you may set the :idp_slo_session_destroy option to a proc that performs the necessary logout tasks.

Example :idp_slo_session_destroy setting for Clearance compatibility:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :saml, idp_slo_session_destroy: proc { |env, _session| env[:clearance].sign_out }, ...
end

Authors

Authored by Rajiv Aaron Manglani, Raecoo Cao, Todd W Saxton, Ryan Wilcox, Steven Anderson, Nikos Dimitrakopoulos, Rudolf Vriend and Bruno Pedro.


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 2 days ago

Total Commits: 207
Total Committers: 55
Avg Commits per committer: 3.764
Development Distribution Score (DDS): 0.821

Commits in past year: 22
Committers in past year: 4
Avg Commits per committer in past year: 5.5
Development Distribution Score (DDS) in past year: 0.364

Name Email Commits
Mike Dillon m****n@d****m 37
Roger Meier r****r@s****m 32
Patricio Cano s****2@g****m 21
Rajiv Aaron Manglani r****v@p****m 17
Gerardo Navarro g****o@b****e 14
Bruno Pedro b****o@b****m 12
Torsten Schoenebaum t****m@s****m 5
James Blanding j****s@b****m 5
Markus Koller m****r@g****h 4
Nikos Dimitrakopoulos n****m@n****m 3
Peter Boling p****g@g****m 3
Mauro Berlanda m****a@g****m 3
Stefan Kahlert k****t@u****e 2
Ben Bodenmiller b****r@g****m 2
Iain Beeston i****n 2
Robert Nubel r****l@g****m 2
Ryan Wilcox r****x@w****m 2
Sam Laane s****e@a****m 2
Steven Anderson s****e@w****t 2
raecoo r****o@g****m 2
Sokratis Vidros s****s@g****m 1
T.J. Schuck tj@t****m 1
Thomas McCallig t****g@q****m 1
Tom Hipkin t****n@g****m 1
Xavier Lange x****e@g****m 1
Yassin Chelabi y****i@v****m 1
rko r****o@i****e 1
Rudolf Vriend r****d@s****m 1
Peter Williams w****s@g****m 1
Otto Vehvilainen v****s@f****m 1
and 25 more...

Committer domains:


Issue and Pull Request metadata

Last synced: 11 days ago

Total issues: 70
Total pull requests: 82
Average time to close issues: 7 months
Average time to close pull requests: 5 months
Total issue authors: 65
Total pull request authors: 35
Average comments per issue: 2.8
Average comments per pull request: 3.76
Merged pull request: 63
Bot issues: 0
Bot pull requests: 0

Past year issues: 6
Past year pull requests: 15
Past year average time to close issues: 4 minutes
Past year average time to close pull requests: 3 days
Past year issue authors: 6
Past year pull request authors: 4
Past year average comments per issue: 1.33
Past year average comments per pull request: 0.47
Past year merged pull request: 10
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/omniauth/omniauth-saml

Top Issue Authors

  • ilikepi (2)
  • dblessing (2)
  • vmvwebworks (2)
  • slalomandrew (2)
  • pitbulk (2)
  • Fenntasy (1)
  • mattiamalonni (1)
  • alim (1)
  • RomanKosovnenko (1)
  • m25n (1)
  • cwseric (1)
  • tommymccallig (1)
  • kanevk (1)
  • Startouf (1)
  • peggles2 (1)

Top Pull Request Authors

  • bufferoverflow (20)
  • md5 (9)
  • gerardo-navarro (6)
  • tosch (4)
  • TzachiF (3)
  • ilikepi (3)
  • machisuji (2)
  • rajiv (2)
  • pboling (2)
  • mberlanda (2)
  • mjfeldmann1 (2)
  • quamen (2)
  • SokratisVidros (2)
  • tjschuck (2)
  • smudge (1)

Top Issue Labels

Top Pull Request Labels


Package metadata

gem.coop: omniauth-saml

A generic SAML strategy for OmniAuth.

  • Homepage: https://github.com/omniauth/omniauth-saml
  • Documentation: http://www.rubydoc.info/gems/omniauth-saml/
  • Licenses: MIT
  • Latest release: 2.2.5 (published 11 days ago)
  • Last Synced: 2026-03-02T06:32:12.349Z (1 day ago)
  • Versions: 35
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 61,973,640 Total
  • Docker Downloads: 580,510,279
  • Rankings:
    • Dependent repos count: 0.0%
    • Dependent packages count: 0.0%
    • Average: 0.151%
    • Docker downloads count: 0.16%
    • Downloads: 0.445%
  • Maintainers (5)
rubygems.org: omniauth-saml

A generic SAML strategy for OmniAuth.


Dependencies

omniauth-saml.gemspec rubygems
  • conventional-changelog ~> 1.2 development
  • coveralls >= 0.8.23 development
  • rack-test ~> 0.6, >= 0.6.3 development
  • rake >= 12.3.3 development
  • rspec ~> 3.4 development
  • simplecov ~> 0.11 development
  • omniauth ~> 2.0
  • ruby-saml ~> 1.12
.github/workflows/ruby.yml actions
  • actions/checkout v2 composite
  • ruby/setup-ruby v1 composite
Gemfile rubygems

Score: 30.9082620308517