[dashboard] Accept basic auth header (#7965)

This commit is contained in:
Jesse Hills 2024-12-17 17:26:16 +13:00 committed by GitHub
parent 3d56397e58
commit 759df7ae6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -108,6 +108,12 @@ def is_authenticated(handler: BaseHandler) -> bool:
return True return True
if settings.using_auth: if settings.using_auth:
if auth_header := handler.request.headers.get("Authorization"):
assert isinstance(auth_header, str)
if auth_header.startswith("Basic "):
auth_decoded = base64.b64decode(auth_header[6:]).decode()
username, password = auth_decoded.split(":", 1)
return settings.check_password(username, password)
return handler.get_secure_cookie(AUTH_COOKIE_NAME) == COOKIE_AUTHENTICATED_YES return handler.get_secure_cookie(AUTH_COOKIE_NAME) == COOKIE_AUTHENTICATED_YES
return True return True