diff options
author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2021-03-07 23:48:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-07 23:48:21 +0200 |
commit | 7c86287a76bb9a1605181972ad19bc62647edf24 (patch) | |
tree | 7c5b337b6a59af6811a48d3a1bb659e89feae39c | |
parent | aeeccd3c70ade71c3a3aab736d21474bdec106c8 (diff) | |
parent | e2ed1b0db99530992fa7b6b8ae15a6f79f11c147 (diff) | |
download | pysaml2-7c86287a76bb9a1605181972ad19bc62647edf24.tar.gz |
Merge pull request #763 from peppelinux/invalid_destination_url
Invalid Destination URL Exception Handling
-rw-r--r-- | src/saml2/response.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/saml2/response.py b/src/saml2/response.py index 50e4f6b0..d8a43bfe 100644 --- a/src/saml2/response.py +++ b/src/saml2/response.py @@ -94,6 +94,9 @@ class StatusAuthnFailed(StatusError): class StatusInvalidAttrNameOrValue(StatusError): pass +class StatusInvalidAuthnResponseStatement(StatusError): + pass + class StatusInvalidNameidPolicy(StatusError): pass @@ -1099,13 +1102,17 @@ class AuthnResponse(StatusResponse): return {"name_id": self.name_id, "came_from": self.came_from, "issuer": self.issuer(), "not_on_or_after": nooa, "authz_decision_info": self.authz_decision_info()} - else: + elif getattr(self.assertion, 'authn_statement', None): authn_statement = self.assertion.authn_statement[0] return {"ava": self.ava, "name_id": self.name_id, "came_from": self.came_from, "issuer": self.issuer(), "not_on_or_after": nooa, "authn_info": self.authn_info(), "session_index": authn_statement.session_index} - + else: + raise StatusInvalidAuthnResponseStatement( + "The Authn Response Statement is not valid" + ) + def __str__(self): return self.xmlstr |