Skip to content

Commit 57f7569

Browse files
author
Hans Hörberg
committed
Added the timestamp when the authentication took place to the authn_info method.
Updated the test to verify the change.
1 parent ffe4be1 commit 57f7569

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/saml2/response.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,10 @@ def authn_info(self):
997997
res = []
998998
for astat in self.assertion.authn_statement:
999999
context = astat.authn_context
1000+
try:
1001+
authn_instant = astat.authn_instant
1002+
except AttributeError:
1003+
authn_instant = ""
10001004
if context:
10011005
try:
10021006
aclass = context.authn_context_class_ref.text
@@ -1007,7 +1011,7 @@ def authn_info(self):
10071011
context.authenticating_authority]
10081012
except AttributeError:
10091013
authn_auth = []
1010-
res.append((aclass, authn_auth))
1014+
res.append((aclass, authn_auth, authn_instant))
10111015
return res
10121016

10131017
def authz_decision_info(self):

tests/test_44_authnresp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
from contextlib import closing
4+
from datetime import datetime
5+
from dateutil import parser
46
from saml2.authn_context import INTERNETPROTOCOLPASSWORD
57

68
from saml2.server import Server
@@ -123,6 +125,9 @@ def test_verify_w_authn(self):
123125
assert len(authn_info) == 1
124126
assert authn_info[0][0] == INTERNETPROTOCOLPASSWORD
125127
assert authn_info[0][1] == ["http://www.example.com/login"]
128+
now = datetime.now()
129+
dt = parser.parse(authn_info[0][2])
130+
assert now.year == dt.year and now.month == dt.month and now.day == dt.day
126131
session_info = self.ar.session_info()
127132
assert session_info["authn_info"] == authn_info
128133

0 commit comments

Comments
 (0)