class
Saml::Response
- Saml::Response
- Saml::SamlMessage
- Reference
- Object
Overview
SAML2 Authentication Response. SAML Response
Everything read from the assertion (NameID, attributes, conditions, ...) comes from the canonical bytes a signature's digest covers, re-parsed on their own, never from a lookup in the received document.
Included Modules
Defined in:
saml/response.crConstant Summary
-
ASSERTION =
"urn:oasis:names:tc:SAML:2.0:assertion" -
AVAILABLE_OPTIONS =
[:allowed_clock_drift, :check_duplicated_attributes, :matches_request_id, :settings, :skip_audience, :skip_authnstatement, :skip_conditions, :skip_destination, :skip_recipient_check, :skip_subject_confirmation] -
Response available options This is not a whitelist to allow people extending Saml:Response and pass custom options
-
DSIG =
"http://www.w3.org/2000/09/xmldsig#" -
PROTOCOL =
"urn:oasis:names:tc:SAML:2.0:protocol" -
SAML_NAMESPACES =
{"p" => PROTOCOL, "a" => ASSERTION, "samlp" => PROTOCOL, "saml" => ASSERTION, "ds" => DSIG} -
XENC =
"http://www.w3.org/2001/04/xmlenc#" -
XSI =
"http://www.w3.org/2001/XMLSchema-instance"
Constructors
-
.new(response : String | Nil, options : Hash = {} of Symbol => OptionValue)
Constructs the SAML Response.
Instance Method Summary
-
#allowed_clock_drift : Time::Span
The allowed clock drift on timing validation (option in seconds or a Time::Span).
-
#assertion_encrypted? : Bool
Checks if the SAML Response contains or not an EncryptedAssertion element
- #assertion_id : String | Nil
-
#attributes : Saml::Attributes
Gets the Attributes from the AttributeStatement element.
-
#audiences : Array(String)
@return [Array] The Audience elements from the Contitions of the SAML Response.
-
#authn_context_class_ref : String | Nil
Gets the AuthnContextClassRef from the AuthnStatement
-
#authn_instant : String | Nil
Gets the AuthnInstant from the AuthnStatement.
-
#conditions : XML::Node | Nil
Gets the Condition Element of the SAML Response if exists.
- #decrypted_document : XMLSecurity::SignedDocument | Nil
-
#destination : String | Nil
@return [String|nil] Destination attribute from the SAML Response.
- #document : XMLSecurity::SignedDocument
- #errors : Array(String)
-
#in_response_to : String | Nil
@return [String|nil] The InResponseTo attribute from the SAML Response.
-
#is_valid?(collect_errors = false) : Bool
Validates the SAML Response with the default values (soft = true) @param collect_errors [Boolean] Stop validation when first error appears or keep validating.
-
#issuers : Array(String)
Gets the Issuers (from Response and Assertion).
-
#name_id : String | Nil
@return [String] the NameID provided by the SAML response from the IdP.
-
#name_id_format : String | Nil
@return [String] the NameID Format provided by the SAML response from the IdP.
-
#name_id_namequalifier : String | Nil
@return [String] the NameID NameQualifier provided by the SAML response from the IdP.
-
#name_id_spnamequalifier : String | Nil
@return [String] the NameID SPNameQualifier provided by the SAML response from the IdP.
- #nameid : String | Nil
- #nameid_format : String | Nil
-
#not_before : Time | Nil
Gets the NotBefore Condition Element value.
-
#not_on_or_after : Time | Nil
Gets the NotOnOrAfter Condition Element value.
- #options : Hash(Symbol, OptionValue)
- #options=(options : Hash(Symbol, OptionValue))
- #response : String
- #response_id : String | Nil
-
#session_expires_at : Time | Nil
Gets the SessionNotOnOrAfter from the AuthnStatement.
-
#sessionindex : String | Nil
Gets the SessionIndex from the AuthnStatement.
- #settings : Saml::Settings
- #settings=(settings : Saml::Settings)
- #soft : Bool
- #soft=(soft : Bool)
-
#status_code : String | Nil
@return [String] StatusCode value from a SAML Response.
-
#status_message : String | Nil
@return [String] the StatusMessage value from a SAML Response.
-
#success? : Bool
Checks if the Status has the "Success" code
Instance methods inherited from module Saml::ErrorHandling
append_error(error_msg : String, soft_override : Bool | Nil = nil) : Bool
append_error,
errors : Array(String)
errors,
reset_errors!
reset_errors!
Instance methods inherited from class Saml::SamlMessage
id(document) : String | Nil
id,
valid_saml?(document, soft = true, check_malformed_doc = true) : Bool
valid_saml?,
version(document) : String | Nil
version
Constructor Detail
Constructs the SAML Response. @param response [String] A base64 encoded SAML response from the IdP (or the XML itself). @param options [Hash] :settings to provide the Saml::Settings object, and the validation options in AVAILABLE_OPTIONS (:allowed_clock_drift in seconds or a Time::Span, :matches_request_id, :skip_* ...). @raise [ArgumentError] if response is nil @raise [ValidationError] if the message is too large, or an encrypted assertion can't be decrypted
Instance Method Detail
The allowed clock drift on timing validation (option in seconds or a Time::Span).
Checks if the SAML Response contains or not an EncryptedAssertion element
Gets the Attributes from the AttributeStatement element. @raise [ValidationError] if :check_duplicated_attributes is set and there are 2+ Attribute with the same Name
@return [Array] The Audience elements from the Contitions of the SAML Response.
Gets the Condition Element of the SAML Response if exists.
@return [String|nil] The InResponseTo attribute from the SAML Response.
Validates the SAML Response with the default values (soft = true) @param collect_errors [Boolean] Stop validation when first error appears or keep validating. (if soft=true) @return [Boolean] TRUE if the SAML Response is valid
Gets the Issuers (from Response and Assertion). @raise [ValidationError] when the Response or the Assertion has no Issuer or more than one
@return [String] the NameID provided by the SAML response from the IdP.
@return [String] the NameID Format provided by the SAML response from the IdP.
@return [String] the NameID NameQualifier provided by the SAML response from the IdP.
@return [String] the NameID SPNameQualifier provided by the SAML response from the IdP.