From 152b2d863d0f09febe39964d16877f9205480338 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 18 Oct 2020 15:14:00 +0200 Subject: [PATCH] api: add fallback for proxies < 0.12 which send authorization without b64 --- azure-pipelines.yml | 1 + passbook/api/auth.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e8c371262..857f17166 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -248,6 +248,7 @@ stages: inputs: script: | docker stop $(docker ps -aq) + docker container prune -f - task: CmdLine@2 displayName: Prepare unittests and coverage for upload inputs: diff --git a/passbook/api/auth.py b/passbook/api/auth.py index 8d0f3f18b..37a702857 100644 --- a/passbook/api/auth.py +++ b/passbook/api/auth.py @@ -22,7 +22,13 @@ def token_from_header(raw_header: bytes) -> Optional[Token]: "Unsupported authentication type, denying", type=auth_type.lower() ) return None - auth_credentials = b64decode(auth_credentials.encode()).decode() + try: + auth_credentials = b64decode(auth_credentials.encode()).decode() + except UnicodeDecodeError: + # TODO: Remove this workaround + # temporary fallback for 0.11 to 0.12 upgrade + # 0.11 and below proxy sends authorization header not base64 encoded + auth_credentials = auth_credentials # Accept credentials with username and without if ":" in auth_credentials: _, password = auth_credentials.split(":")