add fingerprint httpbearer schema
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import Depends, HTTPException, Path
|
||||
from fastapi.security import HTTPBearer, OAuth2PasswordBearer
|
||||
from fastapi.security import (
|
||||
HTTPAuthorizationCredentials,
|
||||
HTTPBearer,
|
||||
OAuth2PasswordBearer,
|
||||
)
|
||||
from jwt import InvalidTokenError
|
||||
|
||||
from src.api.dependacies.db_dep import sessionDep
|
||||
@@ -12,8 +16,10 @@ from src.services.tasks import TaskService
|
||||
from src.services.users import UserService
|
||||
|
||||
http_bearer = HTTPBearer(auto_error=False)
|
||||
|
||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl=f"{settings.api.v1_login_url}/login")
|
||||
AccessTokenDep = Annotated[str, Depends(oauth2_scheme)]
|
||||
# AccessTokenDep = Annotated[str, Depends(oauth2_scheme)]
|
||||
AccessTokenDep = Annotated[HTTPAuthorizationCredentials, Depends(http_bearer)]
|
||||
|
||||
|
||||
async def get_current_user(
|
||||
@@ -25,7 +31,7 @@ async def get_current_user(
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
try:
|
||||
payload = AuthManager.decode_access_token(token, verify_exp)
|
||||
payload = AuthManager.decode_access_token(token.credentials, verify_exp)
|
||||
if payload is None:
|
||||
raise credentials_exception
|
||||
user = TokenData(**payload)
|
||||
|
||||
Reference in New Issue
Block a user