3
3
import re
4
4
import struct
5
5
import base64
6
+ import time
6
7
7
8
from saml2 import time_util
8
9
@@ -42,8 +43,8 @@ class ToEarly(Exception):
42
43
43
44
def valid_ncname (name ):
44
45
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")
47
48
return True
48
49
49
50
@@ -90,8 +91,10 @@ def validate_on_or_after(not_on_or_after, slack):
90
91
now = time_util .utc_now ()
91
92
nooa = calendar .timegm (time_util .str_to_time (not_on_or_after ))
92
93
if now > nooa + slack :
94
+ now_str = time .strftime ('%Y-%M-%dT%H:%M:%SZ' , time .gmtime (now ))
93
95
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 ))
95
98
return nooa
96
99
else :
97
100
return False
@@ -102,8 +105,9 @@ def validate_before(not_before, slack):
102
105
now = time_util .utc_now ()
103
106
nbefore = calendar .timegm (time_util .str_to_time (not_before ))
104
107
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 ))
107
111
return True
108
112
109
113
0 commit comments