summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2021-03-07 23:57:59 +0200
committerGitHub <noreply@github.com>2021-03-07 23:57:59 +0200
commitbc54a8c7771a5918aa18c0514bd8b641f2519419 (patch)
treeb389e0ca0e9bfaa97437279914a5e122307ec20f
parent7c86287a76bb9a1605181972ad19bc62647edf24 (diff)
parent8672d10cd4086e5e22adce925a1264c4c076fecb (diff)
downloadpysaml2-bc54a8c7771a5918aa18c0514bd8b641f2519419.tar.gz
Merge pull request #766 from peppelinux/invalid_assertion
Raise InvalidAssertion exception when assertion requirements are not met
-rw-r--r--src/saml2/response.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/saml2/response.py b/src/saml2/response.py
index d8a43bfe..fcb682b4 100644
--- a/src/saml2/response.py
+++ b/src/saml2/response.py
@@ -67,6 +67,10 @@ class IncorrectlySigned(SAMLError):
pass
+class InvalidAssertion(SAMLError):
+ pass
+
+
class DecryptionFailed(SAMLError):
pass
@@ -923,7 +927,7 @@ class AuthnResponse(StatusResponse):
n_assertions = len(self.response.assertion)
n_assertions_enc = len(self.response.encrypted_assertion)
if n_assertions != 1 and n_assertions_enc != 1 and self.assertion is None:
- raise Exception(
+ raise InvalidAssertion(
"Invalid number of assertions in Response: {n}".format(
n=n_assertions+n_assertions_enc
)