class Saml::IdpMetadataParser

Overview

Auxiliary class to retrieve and parse the Identity Provider Metadata

parse_remote fetches whatever URL it is given (an SSRF risk when the URL comes from a user): validate it before calling. Metadata is parsed with the same strict parser as messages (no DTDs, no entities, no network).

Included Modules

Defined in:

saml/idp_metadata_parser.cr

Constant Summary

DEFAULT_MAX_BYTESIZE = 10000000

Remote metadata larger than this is refused; aggregates may need more (:max_bytesize).

DEFAULT_TIMEOUT = 10.seconds

Class Method Summary

Instance Method Summary

Class Method Detail

def self.get_idps(metadata_document : XML::Node, only_entity_id : String | Nil = nil) : Array(XML::Node) #

fetch IdP descriptors from a metadata document


[View source]

Instance Method Detail

def document : XML::Node | Nil #

[View source]
def options : Hash(Symbol, Array(String) | Bool | Hash(Symbol, Array(String) | Bool | Hash(Symbol, Array(String)) | Hash(Symbol, Bool | Int32 | String | Nil) | Int32 | String | Symbol | Time | Nil) | Int32 | Saml::Settings | String | Nil) #

[View source]
def parse(idp_metadata : String, options : Hash = {} of Symbol => Option) : Settings #

Parses the IdP metadata and returns Settings with the IdP values.

@option options [Saml::Settings, Hash] :settings the Settings to merge the metadata into, or overrides for new Settings @option options [String] :entity_id use the IdP with this entityID (else the first) @option options [String, Array] :sso_binding preferred bindings for the single sign-on URL @option options [String, Array] :slo_binding preferred bindings for the single logout URL @option options [String, Array] :name_id_format preferred NameIDFormat values @raise [ArgumentError] when the metadata has no IDPSSODescriptor @raise [XMLLoadError] when the metadata isn't well-formed or uses DTDs


[View source]
def parse_remote(url : String, validate_cert = true, options : Hash = {} of Symbol => Option) : Settings #

Fetches the IdP metadata and returns Settings with the IdP values. @param url [String] http(s) URL of the metadata @param validate_cert [Boolean] check the server's TLS certificate @param options [Hash] as for #parse, plus :max_bytesize @raise [HttpError] Failure to fetch remote IdP metadata


[View source]
def parse_remote_to_array(url : String, validate_cert = true, options : Hash = {} of Symbol => Option) : Array(Parsed) #

Like parse_remote, returning every IdP's values.


[View source]
def parse_remote_to_hash(url : String, validate_cert = true, options : Hash = {} of Symbol => Option) : Parsed #

Like parse_remote, returning the first IdP's values as a Hash.


[View source]
def parse_to_array(idp_metadata : String, options : Hash = {} of Symbol => Option) : Array(Parsed) #

Parses the metadata and returns every IdP's values (or only :entity_id's).


[View source]
def parse_to_hash(idp_metadata : String, options : Hash = {} of Symbol => Option) : Parsed #

Parses the metadata and returns the first IdP's values as a Hash.


[View source]
def parse_to_idp_metadata_array(idp_metadata : String, options : Hash = {} of Symbol => Option) : Array(IdpMetadata) #

[View source]
def response : HTTP::Client::Response | Nil #

[View source]