From: Michael Tremer Date: Thu, 26 May 2022 11:21:45 +0000 (+0000) Subject: hub: Fix HTTP Basic authentication X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d9cb5c589d59c8b00761f9117791d64bb41642c;p=pbs.git hub: Fix HTTP Basic authentication Signed-off-by: Michael Tremer --- diff --git a/src/hub/handlers.py b/src/hub/handlers.py index 47d566e9..954f98de 100644 --- a/src/hub/handlers.py +++ b/src/hub/handlers.py @@ -41,8 +41,11 @@ class BaseHandler(tornado.web.RequestHandler): raise tornado.web.HTTPError(400, "Can only handle Basic auth.") try: - # Decode the authentication information. - auth_header = base64.decodestring(auth_header[6:]) + # Convert into bytes() + auth_header = auth_header[6:].encode() + + # Decode base64 + auth_header = base64.b64decode(auth_header).decode() name, password = auth_header.split(":", 1) except: @@ -426,7 +429,7 @@ class BuildersBaseHandler(BaseHandler): def prepare(self): # The request must come from an authenticated buider. if not self.builder: - raise tornado.web.HTTPError(403) + raise tornado.web.HTTPError(403, "Not authenticated as a builder") class BuildersInfoHandler(BuildersBaseHandler):