diff options
author | 2024-08-19 04:56:49 +0100 | |
---|---|---|
committer | 2024-08-19 04:56:49 +0100 | |
commit | be2d9974ee9a12cb735eaa0937f5deede8015535 (patch) | |
tree | 1e2664821c8f8c7e360f364d5cc9c361a91a4e34 | |
parent | Change scheme from token to bearer (diff) |
Switch from HTTPBase to HTTPBearer
-rw-r--r-- | thallium-backend/src/auth.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/thallium-backend/src/auth.py b/thallium-backend/src/auth.py index b0a37b5..1f562ae 100644 --- a/thallium-backend/src/auth.py +++ b/thallium-backend/src/auth.py @@ -7,7 +7,7 @@ from uuid import uuid4 import jwt from fastapi import HTTPException, Request from fastapi.security import HTTPAuthorizationCredentials -from fastapi.security.http import HTTPBase +from fastapi.security.http import HTTPBearer from src.dto.users import User, UserPermission from src.settings import CONFIG @@ -22,7 +22,7 @@ class UserTypes(IntFlag): REGULAR_USER = 2**1 -class TokenAuth(HTTPBase): +class TokenAuth(HTTPBearer): """Ensure all requests with this auth enabled include an auth header with the expected token.""" def __init__( @@ -32,7 +32,7 @@ class TokenAuth(HTTPBase): allow_vouchers: bool = False, allow_regular_users: bool = False, ) -> None: - super().__init__(scheme="bearer", auto_error=auto_error) + super().__init__(scheme_name="bearer", bearerFormat="JWT", auto_error=auto_error) self.allow_vouchers = allow_vouchers self.allow_regular_users = allow_regular_users |