Buckets:

download
raw
1.12 kB
# src/auth_rsha/deps.py
from typing import Annotated
from fastapi import Depends, HTTPException, status
from fastapi.security import OAuth2PasswordBearer
from jose import JWTError, ExpiredSignatureError
from .config import AuthSettings
from .jwt import decode_token
from .schemas import TokenPayload
def make_current_user(settings: AuthSettings):
oauth2 = OAuth2PasswordBearer(
tokenUrl=settings.token_url_path,
scheme_name="Bearer",
auto_error=True,
)
async def current_user(token: Annotated[str, Depends(oauth2)]) -> TokenPayload:
try:
return decode_token(token, settings)
except ExpiredSignatureError:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Token expired",
headers={"WWW-Authenticate": "Bearer"},
)
except JWTError:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid token",
headers={"WWW-Authenticate": "Bearer"},
)
return current_user

Xet Storage Details

Size:
1.12 kB
·
Xet hash:
921011bebaf7e7a01cae8d31123a27a9e76daa0172b4e12cce0378d055db7bb9

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.