From c38826824ff872229045623644ae211245b5b1ba Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Tue, 17 Dec 2024 17:26:16 +1300 Subject: [PATCH] [dashboard] Accept basic auth header (#7965) --- esphome/dashboard/web_server.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/esphome/dashboard/web_server.py b/esphome/dashboard/web_server.py index 0fed8e9c53..67712da9b6 100644 --- a/esphome/dashboard/web_server.py +++ b/esphome/dashboard/web_server.py @@ -108,6 +108,12 @@ def is_authenticated(handler: BaseHandler) -> bool: return True 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 True