Skip to content

Commit 9a3b384

Browse files
committed
Fix timestamp validation error message
This fixes 2 things: 1.) First, the values were exchanged according to the comparison order 2.) Second, the slack was not included in the messages, leaving the possibility of printing confusing message. I decided to add or substract (respectively) the slack from "now" instead of nooa/nbefore, since "now" is more volatile and there's a better chance that people could try to search for the nooa/nbefore numbers in the dumps (encapsulated in SAML messages) rather then for the ever-changing value of "now".
1 parent 0e4f5fa commit 9a3b384

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/saml2/validate.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def validate_on_or_after(not_on_or_after, slack):
9191
nooa = calendar.timegm(time_util.str_to_time(not_on_or_after))
9292
if now > nooa + slack:
9393
raise ResponseLifetimeExceed(
94-
"Can't use it, it's too old %d > %d".format(nooa, now))
94+
"Can't use it, it's too old %d > %d".format(now - slack, nooa))
9595
return nooa
9696
else:
9797
return False
@@ -102,8 +102,7 @@ def validate_before(not_before, slack):
102102
now = time_util.utc_now()
103103
nbefore = calendar.timegm(time_util.str_to_time(not_before))
104104
if nbefore > now + slack:
105-
raise ToEarly("Can't use it yet %d <= %d" % (nbefore,
106-
now))
105+
raise ToEarly("Can't use it yet %d <= %d" % (now + slack, nbefore))
107106

108107
return True
109108

0 commit comments

Comments
 (0)