From 4d66490f02d09158a4e58dccd98210de1bb1fd17 Mon Sep 17 00:00:00 2001 From: Keyvan Hardani Date: Wed, 24 Apr 2024 16:59:57 +0200 Subject: [PATCH] Update server.py --- software/source/server/server.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/software/source/server/server.py b/software/source/server/server.py index e92b50d..a9ace26 100644 --- a/software/source/server/server.py +++ b/software/source/server/server.py @@ -147,15 +147,8 @@ async def authenticate(websocket: WebSocket): # Verify the provided token token = auth_response.get("token") - if not token: - await websocket.send_json({"type": "auth_failure"}) - await websocket.close() - return False - - try: - # Use the OAuth2PasswordBearer scheme to validate the token - token = await oauth2_scheme(token) - except Exception: + expected_token = os.getenv("WS_TOKEN") + if token != expected_token: await websocket.send_json({"type": "auth_failure"}) await websocket.close() return False