Class: OmniAuth::Strategies::MPASSid

Inherits:
SAML
  • Object
show all
Defined in:
lib/omniauth/strategies/mpassid.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, *args, &block) ⇒ MPASSid

Returns a new instance of MPASSid.



248
249
250
251
252
253
254
255
256
257
258
# File 'lib/omniauth/strategies/mpassid.rb', line 248

def initialize(app, *args, &block)
  super

  # Add the MPASSid options to the local options, most of which are
  # fetched from the metadata. The options array is the one that gets
  # priority in case it overrides some of the metadata or locally defined
  # option values.
  @options = OmniAuth::Strategy::Options.new(
    mpassid_options.merge(options)
  )
end

Instance Method Details

#callback_urlObject

Override the callback URL so that it always matches the one expected by MPASSid. No additional query string parameters can be included in the string.



292
293
294
# File 'lib/omniauth/strategies/mpassid.rb', line 292

def callback_url
  full_host + script_name + callback_path
end

#request_phaseObject

Override the request phase to be able to pass the lang parameter to the redirect URL. Note that this needs to be the last parameter to be passed to the redirect URL.



263
264
265
266
267
268
269
270
271
272
# File 'lib/omniauth/strategies/mpassid.rb', line 263

def request_phase
  authn_request = OneLogin::RubySaml::Authrequest.new
  lang = lang_for_authn_request

  with_settings do |settings|
    url = authn_request.create(settings, additional_params_for_authn_request)
    url += "&lang=#{CGI.escape(lang)}" unless lang.nil?
    redirect(url)
  end
end

#response_objectObject

This method can be used externally to fetch information about the response, e.g. in case of failures.



276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/omniauth/strategies/mpassid.rb', line 276

def response_object
  return nil unless request.params['SAMLResponse']

  with_settings do |settings|
    response = OneLogin::RubySaml::Response.new(
      request.params['SAMLResponse'],
      options_for_response_object.merge(settings: settings)
    )
    response.attributes['fingerprint'] = settings.idp_cert_fingerprint
    response
  end
end