Class: OmniAuth::Strategies::SAML

Inherits:
Object
  • Object
show all
Includes:
OmniAuth::Strategy
Defined in:
lib/omniauth/strategies/saml.rb,
lib/omniauth/strategies/saml/auth_request.rb,
lib/omniauth/strategies/saml/xml_security.rb,
lib/omniauth/strategies/saml/auth_response.rb,
lib/omniauth/strategies/saml/validation_error.rb

Defined Under Namespace

Modules: XMLSecurity Classes: AuthRequest, AuthResponse, ValidationError

Constant Summary collapse

@@settings =
{}

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ SAML

Returns a new instance of SAML.



14
15
16
17
18
19
20
21
22
23
# File 'lib/omniauth/strategies/saml.rb', line 14

def initialize(app, options={})
  super( app, (options[:name] || :saml) )
  @@settings = {
    :assertion_consumer_service_url => options[:assertion_consumer_service_url],
    :issuer                         => options[:issuer],
    :idp_sso_target_url             => options[:idp_sso_target_url],
    :idp_cert_fingerprint           => options[:idp_cert_fingerprint],
    :name_identifier_format         => options[:name_identifier_format] || "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"
  }
end

Instance Method Details

#auth_hashObject



43
44
45
46
47
48
# File 'lib/omniauth/strategies/saml.rb', line 43

def auth_hash
  OmniAuth::Utils.deep_merge(super, {
    'uid' => @name_id,
    'extra' => @extra_attributes
  })
end

#callback_phaseObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/omniauth/strategies/saml.rb', line 30

def callback_phase
  begin
    response = OmniAuth::Strategies::SAML::AuthResponse.new(request.params['SAMLResponse'])
    response.settings = @@settings
    @name_id  = response.name_id
    @extra_attributes = response.attributes
    return fail!(:invalid_ticket, 'Invalid SAML Ticket') if @name_id.nil? || @name_id.empty?
    super
  rescue ArgumentError => e
    fail!(:invalid_ticket, 'Invalid SAML Response')
  end
end

#request_phaseObject



25
26
27
28
# File 'lib/omniauth/strategies/saml.rb', line 25

def request_phase
  request = OmniAuth::Strategies::SAML::AuthRequest.new
  redirect(request.create(@@settings))
end