33import re
44import struct
55import base64
6+ import time
67
78from saml2 import time_util
89
@@ -42,8 +43,8 @@ class ToEarly(Exception):
4243
4344def 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