Spaces:
Sleeping
Sleeping
File size: 816 Bytes
7006220 a38b4f9 7006220 a38b4f9 7006220 a38b4f9 7006220 a38b4f9 7006220 a38b4f9 7006220 a38b4f9 7006220 a38b4f9 7006220 a38b4f9 7006220 a38b4f9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#from fastapi import Depends, HTTPException, status
from fastapi import HTTPException, Security
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from starlette.status import HTTP_403_FORBIDDEN
from fastapi import Security
from fastapi.security import HTTPBearer
bearer_scheme = HTTPBearer()
#security = HTTPBearer()
from fastapi import Header, HTTPException, Depends
VALID_TOKENS = ["my_secure_token_123"] # or load from file/db/env
def verify_token(credentials: HTTPAuthorizationCredentials = Security(bearer_scheme)):
token = credentials.credentials
# Replace with your actual logic (static check shown here)
if token != "my_secure_token_123":
raise HTTPException(
status_code=HTTP_403_FORBIDDEN,
detail="Invalid or expired token"
)
|