@@ -32,7 +32,7 @@ class Response < SamlMessage
32
32
33
33
# Constructs the SAML Response. A Response Object that is an extension of the SamlMessage class.
34
34
# @param response [String] A UUEncoded SAML response from the IdP.
35
- # @param options [Hash] :settings to provide the OneLogin::RubySaml::Settings object
35
+ # @param options [Hash] :settings to provide the OneLogin::RubySaml::Settings object
36
36
# Or some options for the response validation process like skip the conditions validation
37
37
# with the :skip_conditions, or allow a clock_drift when checking dates with :allowed_clock_drift
38
38
# or :matches_request_id that will validate that the response matches the ID of the request,
@@ -189,7 +189,7 @@ def session_expires_at
189
189
190
190
# Checks if the Status has the "Success" code
191
191
# @return [Boolean] True if the StatusCode is Sucess
192
- #
192
+ #
193
193
def success?
194
194
status_code == "urn:oasis:names:tc:SAML:2.0:status:Success"
195
195
end
@@ -376,15 +376,15 @@ def validate(collect_errors = false)
376
376
#
377
377
def validate_success_status
378
378
return true if success?
379
-
379
+
380
380
error_msg = 'The status code of the Response was not Success'
381
381
status_error_msg = OneLogin ::RubySaml ::Utils . status_error_msg ( error_msg , status_code , status_message )
382
382
append_error ( status_error_msg )
383
383
end
384
384
385
385
# Validates the SAML Response against the specified schema.
386
386
# @return [Boolean] True if the XML is valid, otherwise False if soft=True
387
- # @raise [ValidationError] if soft == false and validation fails
387
+ # @raise [ValidationError] if soft == false and validation fails
388
388
#
389
389
def validate_structure
390
390
structure_error_msg = "Invalid SAML Response. Not match the saml-schema-protocol-2.0.xsd"
@@ -417,7 +417,7 @@ def validate_response_state
417
417
true
418
418
end
419
419
420
- # Validates that the SAML Response contains an ID
420
+ # Validates that the SAML Response contains an ID
421
421
# If fails, the error is added to the errors array.
422
422
# @return [Boolean] True if the SAML Response contains an ID, otherwise returns False
423
423
#
@@ -706,7 +706,7 @@ def validate_session_expiration(soft = true)
706
706
end
707
707
708
708
# Validates if exists valid SubjectConfirmation (If the response was initialized with the :allowed_clock_drift option,
709
- # timimg validation are relaxed by the allowed_clock_drift value. If the response was initialized with the
709
+ # timimg validation are relaxed by the allowed_clock_drift value. If the response was initialized with the
710
710
# :skip_subject_confirmation option, this validation is skipped)
711
711
# If fails, the error is added to the errors array
712
712
# @return [Boolean] True if exists a valid SubjectConfirmation, otherwise False if soft=True
@@ -717,7 +717,7 @@ def validate_subject_confirmation
717
717
valid_subject_confirmation = false
718
718
719
719
subject_confirmation_nodes = xpath_from_signed_assertion ( '/a:Subject/a:SubjectConfirmation' )
720
-
720
+
721
721
now = Time . now . utc
722
722
subject_confirmation_nodes . each do |subject_confirmation |
723
723
if subject_confirmation . attributes . include? "Method" and subject_confirmation . attributes [ 'Method' ] != 'urn:oasis:names:tc:SAML:2.0:cm:bearer'
@@ -735,8 +735,9 @@ def validate_subject_confirmation
735
735
attrs = confirmation_data_node . attributes
736
736
next if ( attrs . include? "InResponseTo" and attrs [ 'InResponseTo' ] != in_response_to ) ||
737
737
( attrs . include? "NotOnOrAfter" and ( parse_time ( confirmation_data_node , "NotOnOrAfter" ) + allowed_clock_drift ) <= now ) ||
738
- ( attrs . include? "NotBefore" and parse_time ( confirmation_data_node , "NotBefore" ) > ( now + allowed_clock_drift ) )
739
-
738
+ ( attrs . include? "NotBefore" and parse_time ( confirmation_data_node , "NotBefore" ) > ( now + allowed_clock_drift ) ) ||
739
+ ( attrs . include? "Recipient" and settings . assertion_consumer_service_url != nil and attrs [ 'Recipient' ] != settings . assertion_consumer_service_url )
740
+
740
741
valid_subject_confirmation = true
741
742
break
742
743
end
@@ -808,7 +809,7 @@ def validate_signature
808
809
opts [ :cert ] = settings . get_idp_cert
809
810
fingerprint = settings . get_fingerprint
810
811
811
- unless fingerprint && doc . validate_document ( fingerprint , @soft , opts )
812
+ unless fingerprint && doc . validate_document ( fingerprint , @soft , opts )
812
813
return append_error ( error_msg )
813
814
end
814
815
0 commit comments