Skip to content

Commit b4fd726

Browse files
committed
Refactor saml2.response.Response.authn_info
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 176d216 commit b4fd726

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/saml2/response.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,23 +1071,27 @@ def id(self):
10711071

10721072
def authn_info(self):
10731073
res = []
1074-
for astat in self.assertion.authn_statement:
1075-
context = astat.authn_context
1074+
for statement in self.assertion.authn_statement:
10761075
try:
1077-
authn_instant = astat.authn_instant
1076+
authn_instant = statement.authn_instant
10781077
except AttributeError:
10791078
authn_instant = ""
1080-
if context:
1081-
try:
1082-
aclass = context.authn_context_class_ref.text
1083-
except AttributeError:
1084-
aclass = ""
1085-
try:
1086-
authn_auth = [a.text for a in
1087-
context.authenticating_authority]
1088-
except AttributeError:
1089-
authn_auth = []
1090-
res.append((aclass, authn_auth, authn_instant))
1079+
1080+
context = statement.authn_context
1081+
if not context:
1082+
continue
1083+
1084+
try:
1085+
authn_class = context.authn_context_class_ref.text
1086+
except AttributeError:
1087+
authn_class = ""
1088+
1089+
try:
1090+
authn_auth = [a.text for a in context.authenticating_authority]
1091+
except AttributeError:
1092+
authn_auth = []
1093+
1094+
res.append((authn_class, authn_auth, authn_instant))
10911095
return res
10921096

10931097
def authz_decision_info(self):

0 commit comments

Comments
 (0)