]> git.ipfire.org Git - pbs.git/commitdiff
hub: Fix HTTP Basic authentication
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 May 2022 11:21:45 +0000 (11:21 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 May 2022 11:21:45 +0000 (11:21 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/hub/handlers.py

index 47d566e9cf6ca614d7942abf767efc08752a7704..954f98de7a8714fbf7e615b4dc9cdf5b7e7a2041 100644 (file)
@@ -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):