From 6f998a3c584a59511c55cce305775fff7ed6d441 Mon Sep 17 00:00:00 2001 From: BluemediaGER Date: Sun, 14 Apr 2024 23:23:51 +0200 Subject: [PATCH] Use chargepoint identity for basic auth to be spec compliant --- app/util/websocket_auth_backend.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/util/websocket_auth_backend.py b/app/util/websocket_auth_backend.py index a3260a6..cf1146a 100644 --- a/app/util/websocket_auth_backend.py +++ b/app/util/websocket_auth_backend.py @@ -1,6 +1,5 @@ import base64 import binascii -from uuid import UUID from starlette.authentication import ( AuthCredentials, AuthenticationBackend, AuthenticationError, SimpleUser ) @@ -23,13 +22,9 @@ class BasicAuthBackend(AuthenticationBackend): raise AuthenticationError('Invalid basic auth credentials') username, _, password = decoded.partition(":") - try: - id = UUID(username) - except (ValueError) as exc: - raise AuthenticationError('Invalid basic auth credentials') with SessionLocal() as db: - chargepoint = db.query(ChargePoint).filter(ChargePoint.id == id).first() + chargepoint = db.query(ChargePoint).filter(ChargePoint.friendly_name == username).first() if chargepoint is None: raise AuthenticationError('Invalid basic auth credentials') if chargepoint.password != password: