sources/saml: improve error handling for missing assertion and missing subject
closes #3784 Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
febe3a5477
commit
0ca1368dcc
|
@ -163,10 +163,14 @@ class ResponseProcessor:
|
|||
def _get_name_id(self) -> "Element":
|
||||
"""Get NameID Element"""
|
||||
assertion = self._root.find("{urn:oasis:names:tc:SAML:2.0:assertion}Assertion")
|
||||
if not assertion:
|
||||
raise ValueError("Assertion element not found")
|
||||
subject = assertion.find("{urn:oasis:names:tc:SAML:2.0:assertion}Subject")
|
||||
if not subject:
|
||||
raise ValueError("Subject element not found")
|
||||
name_id = subject.find("{urn:oasis:names:tc:SAML:2.0:assertion}NameID")
|
||||
if name_id is None:
|
||||
raise ValueError("NameID Element not found!")
|
||||
raise ValueError("NameID element not found")
|
||||
return name_id
|
||||
|
||||
def _get_name_id_filter(self) -> dict[str, str]:
|
||||
|
|
|
@ -163,7 +163,7 @@ class ACSView(View):
|
|||
|
||||
try:
|
||||
return processor.prepare_flow(request)
|
||||
except UnsupportedNameIDFormat as exc:
|
||||
except (UnsupportedNameIDFormat, ValueError) as exc:
|
||||
return bad_request_message(request, str(exc))
|
||||
|
||||
|
||||
|
|
Reference in New Issue