File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -515,7 +515,7 @@ def validate_session_expiration(soft = true)
515
515
return true if session_expires_at . nil?
516
516
517
517
now = Time . now . utc
518
- unless session_expires_at > ( now + allowed_clock_drift )
518
+ unless ( session_expires_at + allowed_clock_drift ) > now
519
519
error_msg = "The attributes have expired, based on the SessionNotOnOrAfter of the AttributeStatement of this Response"
520
520
return append_error ( error_msg )
521
521
end
Original file line number Diff line number Diff line change @@ -630,6 +630,18 @@ class RubySamlTest < Minitest::Test
630
630
assert !response . send ( :validate_session_expiration )
631
631
assert_includes response . errors , "The attributes have expired, based on the SessionNotOnOrAfter of the AttributeStatement of this Response"
632
632
end
633
+
634
+ it "returns true when the session has expired, but is still within the allowed_clock_drift" do
635
+ drift = ( Time . now - Time . parse ( "2010-11-19T21:57:37Z" ) ) * 60 # minutes ago that this assertion expired
636
+ drift += 10 # add a buffer of 10 minutes to make sure the test passes
637
+ opts = { }
638
+ opts [ :allowed_clock_drift ] = drift
639
+
640
+ response_with_drift = OneLogin ::RubySaml ::Response . new ( response_document_without_recipient , opts )
641
+ response_with_drift . settings = settings
642
+ assert response_with_drift . send ( :validate_session_expiration )
643
+ assert_empty response_with_drift . errors
644
+ end
633
645
end
634
646
635
647
describe "#validate_signature" do
You can’t perform that action at this time.
0 commit comments