From 788f24cff778e53e908f8c6a52467f4f21ac01c0 Mon Sep 17 00:00:00 2001 From: ignis32 Date: Wed, 24 Nov 2021 19:22:28 +0300 Subject: [PATCH] Fixed OPDS basic auth for android Coolreader --- opds_catalog/middleware.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/opds_catalog/middleware.py b/opds_catalog/middleware.py index e97d6733..2b960857 100644 --- a/opds_catalog/middleware.py +++ b/opds_catalog/middleware.py @@ -34,12 +34,18 @@ def process_request(self,request): authentication = request.META[self.header] except KeyError: return self.unauthed() - - (auth_meth, auth_data) = authentication.split(' ',1) - if 'basic' != auth_meth.lower(): - return self.unauthed() + + try: + (auth_meth, auth_data) = authentication.split(' ',1) + except: + auth_meth="basic" + auth_data=authentication + + if 'basic' != auth_meth.lower(): + return self.unauthed() auth_data = base64.b64decode(auth_data.strip()).decode('utf-8') username, password = auth_data.split(':',1) + user = auth.authenticate(username=username, password=password) if user and user.is_active: