Module: OmniAuth::Realme

Defined in:
lib/omniauth/realme.rb,
lib/omniauth/realme/version.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
'2.1.2'

Class Method Summary collapse

Class Method Details

.generate_metadata_xml(options: {}) ⇒ String

Generates SAML SP metadata XML using the same settings you used to configure the OmniAuth strategy. This XML is suitable for uploading to Realme at mts.realme.govt.nz/logon-mts/metadataupdate

Parameters:

  • options (Hash) (defaults to: {})
    • An optional Hash of options to configure the

    strategy. This is convenient for testing but is not required during normal operation because the strategy will already be configured by the Rails initializer.

Returns:

  • (String)

    SP metadata serialized as an XML string



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/omniauth/realme.rb', line 22

def self.(options: {})
  meta = OneLogin::RubySaml::Metadata.new

  # OmniAuth strategies are Rack middlewares. When an instance of a rack
  # middleware is created it is given a reference to the next rack
  # app/middleware in the chain. We are only interested here in getting the
  # SAML settings out of the strategy. We don't hit any code paths which
  # would require a real rack app/middleware so `nil` works just fine.
  rack_app = nil

  # The Rails initializer calls `OmniAuth::Strategies::Realme.configure`
  # which merges the provided block into the default options for
  # `OmniAuth::Strategies::Realme` - use
  # `OmniAuth::Strategies::Realme.default_options` to inspect the current
  # state of these options.
  #
  # This means that the `options` we pass in here will be merged into (and
  # override) those default options.
  #
  # When this method is called by app code, we want to use the options set
  # by the Rails initializer so pass an empty hash as `options`. When this
  # method is called by its specs, no Rails initializer has run so we need
  # to pass in some options.
  #
  strategy = OmniAuth::Strategies::Realme.new(rack_app, options)

  meta.generate(strategy.saml_settings)
end