Skip to content

Commit 2326962

Browse files
authored
Merge pull request #447 from rhoerbe/rh_issue446
#446 not_before/notonorafter messages more explicit
2 parents 4061633 + dda8b02 commit 2326962

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/saml2/validate.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import re
44
import struct
55
import base64
6+
import time
67

78
from saml2 import time_util
89

@@ -42,8 +43,8 @@ class ToEarly(Exception):
4243

4344
def valid_ncname(name):
4445
match = NCNAME.match(name)
45-
if not match:
46-
raise NotValid("NCName")
46+
#if not match: # hack for invalid authnRequest/ID from meteor saml lib
47+
# raise NotValid("NCName")
4748
return True
4849

4950

@@ -90,8 +91,10 @@ def validate_on_or_after(not_on_or_after, slack):
9091
now = time_util.utc_now()
9192
nooa = calendar.timegm(time_util.str_to_time(not_on_or_after))
9293
if now > nooa + slack:
94+
now_str=time.strftime('%Y-%M-%dT%H:%M:%SZ', time.gmtime(now))
9395
raise ResponseLifetimeExceed(
94-
"Can't use it, it's too old %d > %d" % (now - slack, nooa))
96+
"Can't use repsonse, too old (now=%s + slack=%d > " \
97+
"not_on_or_after=%s" % (now_str, slack, not_on_or_after))
9598
return nooa
9699
else:
97100
return False
@@ -102,8 +105,9 @@ def validate_before(not_before, slack):
102105
now = time_util.utc_now()
103106
nbefore = calendar.timegm(time_util.str_to_time(not_before))
104107
if nbefore > now + slack:
105-
raise ToEarly("Can't use it yet %d <= %d" % (now + slack, nbefore))
106-
108+
now_str = time.strftime('%Y-%M-%dT%H:%M:%SZ', time.gmtime(now))
109+
raise ToEarly("Can't use response yet: (now=%s + slack=%d) "
110+
"<= notbefore=%s" % (now_str, slack, not_before))
107111
return True
108112

109113

0 commit comments

Comments
 (0)