summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2021-08-30 22:41:12 +0300
committerIvan Kanakarakis <ivan.kanak@gmail.com>2021-08-30 22:41:12 +0300
commitf0a6d63c315e5ec0a47419d28720f25ceb359212 (patch)
tree6569cb21fd0743bd1ae09a46442f69aacb0833bd
parent0f1f27f07e3cfd142d18189cea02753cc808fe8c (diff)
downloadpysaml2-f0a6d63c315e5ec0a47419d28720f25ceb359212.tar.gz
Allow AuthnStatement to be optional
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
-rw-r--r--src/saml2/response.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/saml2/response.py b/src/saml2/response.py
index f24ccc7d..a050d58e 100644
--- a/src/saml2/response.py
+++ b/src/saml2/response.py
@@ -1076,11 +1076,8 @@ class AuthnResponse(StatusResponse):
def authn_info(self):
res = []
- for statement in self.assertion.authn_statement:
- try:
- authn_instant = statement.authn_instant
- except AttributeError:
- authn_instant = ""
+ for statement in getattr(self.assertion, 'authn_statement', []):
+ authn_instant = getattr(statement, "authn_instant", "")
context = statement.authn_context
if not context:
@@ -1094,10 +1091,10 @@ class AuthnResponse(StatusResponse):
except AttributeError:
authn_class = ""
- try:
- authn_auth = [a.text for a in context.authenticating_authority]
- except AttributeError:
- authn_auth = []
+ authenticating_authorities = getattr(
+ context, "authenticating_authority", []
+ )
+ authn_auth = [authority.text for authority in authenticating_authorities]
res.append((authn_class, authn_auth, authn_instant))
return res