From 19f2706dc87ad99293284f1919bd0f877ba4b207 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Tue, 22 Apr 2025 23:09:50 +0200 Subject: [PATCH] Change the authorization header to X-Token --- src/xmpp_api/db/__init__.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/xmpp_api/db/__init__.py b/src/xmpp_api/db/__init__.py index 4e7e146..ee7c954 100644 --- a/src/xmpp_api/db/__init__.py +++ b/src/xmpp_api/db/__init__.py @@ -30,17 +30,10 @@ SessionDep = Annotated[Session, Depends(get_session)] def get_by_token( cls: type[SQLModel], request: Request, session: SessionDep ) -> SQLModel: - authorization = request.headers.get("Authorization") - if authorization is None: + token = request.headers.get("X-Token") + if token is None: raise HTTPException( - detail="No authentication provided", - status_code=400, - ) - - auth_type, token = authorization.split(" ") - if auth_type != "Token": - raise HTTPException( - detail="Invalid token type provided", + detail="No token provided", status_code=400, )