Skip to content

Commit f0a6d63

Browse files
committed
Allow AuthnStatement to be optional
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 0f1f27f commit f0a6d63

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/saml2/response.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,11 +1076,8 @@ def id(self):
10761076

10771077
def authn_info(self):
10781078
res = []
1079-
for statement in self.assertion.authn_statement:
1080-
try:
1081-
authn_instant = statement.authn_instant
1082-
except AttributeError:
1083-
authn_instant = ""
1079+
for statement in getattr(self.assertion, 'authn_statement', []):
1080+
authn_instant = getattr(statement, "authn_instant", "")
10841081

10851082
context = statement.authn_context
10861083
if not context:
@@ -1094,10 +1091,10 @@ def authn_info(self):
10941091
except AttributeError:
10951092
authn_class = ""
10961093

1097-
try:
1098-
authn_auth = [a.text for a in context.authenticating_authority]
1099-
except AttributeError:
1100-
authn_auth = []
1094+
authenticating_authorities = getattr(
1095+
context, "authenticating_authority", []
1096+
)
1097+
authn_auth = [authority.text for authority in authenticating_authorities]
11011098

11021099
res.append((authn_class, authn_auth, authn_instant))
11031100
return res

0 commit comments

Comments
 (0)