Class: OmniAuth::Strategies::MPASSid

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of MPASSid.



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

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.
  @mpassid_thread = Thread.new do
    @options = OmniAuth::Strategy::Options.new(
      mpassid_options.merge(options)
    )
    options[:security][:authn_requests_signed] = false unless options[:certificate] && options[:private_key]
  end
end

Instance Attribute Details

#mpassid_threadObject (readonly)

Returns the value of attribute mpassid_thread.



244
245
246
# File 'lib/omniauth/strategies/mpassid.rb', line 244

def mpassid_thread
  @mpassid_thread
end

#optionsObject

Returns the value of attribute options.



243
244
245
# File 'lib/omniauth/strategies/mpassid.rb', line 243

def options
  @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.



296
297
298
# File 'lib/omniauth/strategies/mpassid.rb', line 296

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.



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

def request_phase
  mpassid_thread.join if mpassid_thread.alive?
  authn_request = OneLogin::RubySaml::Authrequest.new
  lang = lang_for_authn_request

  session['saml_redirect_url'] = request.params['redirect_url']

  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.



280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/omniauth/strategies/mpassid.rb', line 280

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