class Saml::Response

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.cr

Constant 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

Instance Method Summary

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

def self.new(response : String | Nil, options : Hash = {} of Symbol => OptionValue) #

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


[View source]

Instance Method Detail

def allowed_clock_drift : Time::Span #

The allowed clock drift on timing validation (option in seconds or a Time::Span).


[View source]
def assertion_encrypted? : Bool #

Checks if the SAML Response contains or not an EncryptedAssertion element


[View source]
def assertion_id : String | Nil #

[View source]
def attributes : Saml::Attributes #

Gets the Attributes from the AttributeStatement element. @raise [ValidationError] if :check_duplicated_attributes is set and there are 2+ Attribute with the same Name


[View source]
def audiences : Array(String) #

@return [Array] The Audience elements from the Contitions of the SAML Response.


[View source]
def authn_context_class_ref : String | Nil #

Gets the AuthnContextClassRef from the AuthnStatement


[View source]
def authn_instant : String | Nil #

Gets the AuthnInstant from the AuthnStatement.


[View source]
def conditions : XML::Node | Nil #

Gets the Condition Element of the SAML Response if exists.


[View source]
def decrypted_document : XMLSecurity::SignedDocument | Nil #

[View source]
def destination : String | Nil #

@return [String|nil] Destination attribute from the SAML Response.


[View source]

[View source]
def errors : Array(String) #

[View source]
def in_response_to : String | Nil #

@return [String|nil] The InResponseTo attribute from the SAML Response.


[View source]
def 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. (if soft=true) @return [Boolean] TRUE if the SAML Response is valid


[View source]
def issuers : Array(String) #

Gets the Issuers (from Response and Assertion). @raise [ValidationError] when the Response or the Assertion has no Issuer or more than one


[View source]
def name_id : String | Nil #

@return [String] the NameID provided by the SAML response from the IdP.


[View source]
def name_id_format : String | Nil #

@return [String] the NameID Format provided by the SAML response from the IdP.


[View source]
def name_id_namequalifier : String | Nil #

@return [String] the NameID NameQualifier provided by the SAML response from the IdP.


[View source]
def name_id_spnamequalifier : String | Nil #

@return [String] the NameID SPNameQualifier provided by the SAML response from the IdP.


[View source]
def nameid : String | Nil #

[View source]
def nameid_format : String | Nil #

[View source]
def not_before : Time | Nil #

Gets the NotBefore Condition Element value.


[View source]
def not_on_or_after : Time | Nil #

Gets the NotOnOrAfter Condition Element value.


[View source]
def options : Hash(Symbol, OptionValue) #

[View source]
def options=(options : Hash(Symbol, OptionValue)) #

[View source]
def response : String #

[View source]
def response_id : String | Nil #

[View source]
def session_expires_at : Time | Nil #

Gets the SessionNotOnOrAfter from the AuthnStatement.


[View source]
def sessionindex : String | Nil #

Gets the SessionIndex from the AuthnStatement.


[View source]
def settings : Saml::Settings #

[View source]
def settings=(settings : Saml::Settings) #

[View source]
def soft : Bool #

[View source]
def soft=(soft : Bool) #

[View source]
def status_code : String | Nil #

@return [String] StatusCode value from a SAML Response.


[View source]
def status_message : String | Nil #

@return [String] the StatusMessage value from a SAML Response.


[View source]
def success? : Bool #

Checks if the Status has the "Success" code


[View source]