Class: OneLogin::RubySaml::IdpMetadataParser

Inherits:
Object
  • Object
show all
Defined in:
lib/onelogin/ruby-saml/idp_metadata_parser.rb

Overview

Auxiliary class to retrieve and parse the Identity Provider Metadata

Constant Summary collapse

METADATA =
"urn:oasis:names:tc:SAML:2.0:metadata"
DSIG =
"http://www.w3.org/2000/09/xmldsig#"
NAME_FORMAT =
"urn:oasis:names:tc:SAML:2.0:attrname-format:*"
SAML_ASSERTION =
"urn:oasis:names:tc:SAML:2.0:assertion"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



23
24
25
# File 'lib/onelogin/ruby-saml/idp_metadata_parser.rb', line 23

def document
  @document
end

#responseObject (readonly)

Returns the value of attribute response.



24
25
26
# File 'lib/onelogin/ruby-saml/idp_metadata_parser.rb', line 24

def response
  @response
end

Instance Method Details

#parse(idp_metadata, options = {}) ⇒ Object

Parse the Identity Provider metadata and update the settings with the IdP values

Parameters:

  • idp_metadata (String)
  • options (Hash) (defaults to: {})

    :settings to provide the OneLogin::RubySaml::Settings object or an hash for Settings overrides



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/onelogin/ruby-saml/idp_metadata_parser.rb', line 42

def parse(, options = {})
  @document = REXML::Document.new()

  settings = options[:settings]
  if settings.nil? || settings.is_a?(Hash)
    settings = OneLogin::RubySaml::Settings.new(settings || {})
  end

  settings.tap do |settings|
    settings.idp_entity_id = idp_entity_id
    settings.name_identifier_format = idp_name_id_format
    settings.idp_sso_target_url = single_signon_service_url(options)
    settings.idp_slo_target_url = single_logout_service_url(options)
    settings.idp_cert = certificate_base64
    settings.idp_cert_fingerprint = fingerprint(settings.idp_cert_fingerprint_algorithm)
    settings.idp_attribute_names = attribute_names
  end
end

#parse_remote(url, validate_cert = true, options = {}) ⇒ REXML::document

Parse the Identity Provider metadata and update the settings with the IdP values

Parameters:

  • options (Hash) (defaults to: {})

    :settings to provide the OneLogin::RubySaml::Settings object or an hash for Settings overrides

  • url (String)

    Url where the XML of the Identity Provider Metadata is published.

  • validate_cert (Boolean) (defaults to: true)

    If true and the URL is HTTPs, the cert of the domain is checked.

Returns:

  • (REXML::document)

    Parsed XML IdP metadata

Raises:

  • (HttpError)

    Failure to fetch remote IdP metadata



33
34
35
36
# File 'lib/onelogin/ruby-saml/idp_metadata_parser.rb', line 33

def parse_remote(url, validate_cert = true, options = {})
   = (url, validate_cert)
  parse(, options)
end