From 447e81d0b8900daf42e5347fa923e85f781bdf26 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 16 Feb 2020 14:08:35 +0100 Subject: [PATCH] providers/saml: handle uncompressed SAML AuthNRequest --- passbook/providers/saml/processors/base.py | 5 +++-- passbook/providers/saml/utils/encoding.py | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/passbook/providers/saml/processors/base.py b/passbook/providers/saml/processors/base.py index e957e0f72..067195ae0 100644 --- a/passbook/providers/saml/processors/base.py +++ b/passbook/providers/saml/processors/base.py @@ -159,8 +159,9 @@ class Processor: request_acs_url = self._request_params["ACS_URL"] if self._remote.acs_url != request_acs_url: - msg = "couldn't find ACS url '{}' in SAML2IDP_REMOTES " "setting.".format( - request_acs_url + msg = ( + f"ACS URL of {request_acs_url} doesn't match Provider " + f"ACS URL of {self._remote.acs_url}." ) self._logger.info(msg) raise CannotHandleAssertion(msg) diff --git a/passbook/providers/saml/utils/encoding.py b/passbook/providers/saml/utils/encoding.py index 59461d45a..9fe6b662a 100644 --- a/passbook/providers/saml/utils/encoding.py +++ b/passbook/providers/saml/utils/encoding.py @@ -6,7 +6,10 @@ import zlib def decode_base64_and_inflate(b64string): """Base64 decode and ZLib decompress b64string""" decoded_data = base64.b64decode(b64string) - return zlib.decompress(decoded_data, -15) + try: + return zlib.decompress(decoded_data, -15) + except zlib.error: + return decoded_data def deflate_and_base64_encode(string_val):