Skip to content

Commit f974cdc

Browse files
committed
NotBefore condition in the Assertion Conditions is not mandatory. If it is not specified, use yesterday as not_before condition
1 parent cd7ee7e commit f974cdc

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

onelogin/saml/Response.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import base64
22

33
from lxml import etree
4-
from datetime import datetime
4+
from datetime import datetime, timedelta
55

66
from onelogin.saml import SignatureVerifier
77

@@ -103,22 +103,23 @@ def is_valid(
103103
namespaces=namespaces,
104104
)
105105

106+
now = _clock()
107+
106108
not_before = None
107109
not_on_or_after = None
108110
for condition in conditions:
109111
not_on_or_after = condition.attrib.get('NotOnOrAfter', None)
110112
not_before = condition.attrib.get('NotBefore', None)
111113

112114
if not_before is None:
113-
raise ResponseConditionError('Did not find NotBefore condition')
115+
#notbefore condition is not mandatory. If it is not specified, use yesterday as not_before condition
116+
not_before = (now-timedelta(1,0,0)).strftime('%Y-%m-%dT%H:%M:%SZ')
114117
if not_on_or_after is None:
115118
raise ResponseConditionError('Did not find NotOnOrAfter condition')
116119

117120
not_before = self._parse_datetime(not_before)
118121
not_on_or_after = self._parse_datetime(not_on_or_after)
119122

120-
now = _clock()
121-
122123
if now < not_before:
123124
raise ResponseValidationError(
124125
'Current time is earlier than NotBefore condition'

0 commit comments

Comments
 (0)