providers/saml: handle parse error

AUTHENTIK-1K5

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-05-23 22:02:52 +02:00
parent 8c9748e4a0
commit 61a876b582
1 changed files with 5 additions and 1 deletions

View File

@ -3,6 +3,7 @@ from base64 import b64decode
from dataclasses import dataclass from dataclasses import dataclass
from typing import Optional from typing import Optional
from urllib.parse import quote_plus from urllib.parse import quote_plus
from xml.etree.ElementTree import ParseError # nosec
import xmlsec import xmlsec
from defusedxml import ElementTree from defusedxml import ElementTree
@ -175,7 +176,10 @@ class AuthNRequestParser:
) )
except xmlsec.Error as exc: except xmlsec.Error as exc:
raise CannotHandleAssertion(ERROR_FAILED_TO_VERIFY) from exc raise CannotHandleAssertion(ERROR_FAILED_TO_VERIFY) from exc
return self._parse_xml(decoded_xml, relay_state) try:
return self._parse_xml(decoded_xml, relay_state)
except ParseError as exc:
raise CannotHandleAssertion(ERROR_FAILED_TO_VERIFY) from exc
def idp_initiated(self) -> AuthNRequest: def idp_initiated(self) -> AuthNRequest:
"""Create IdP Initiated AuthNRequest""" """Create IdP Initiated AuthNRequest"""