prism-api / web /api /auth.py
nasa718's picture
purge history: collapse to code-only tree (no parquet)
50e4044
Raw
History Blame Contribute Delete
511 Bytes
from __future__ import annotations
from fastapi import Header, HTTPException, status
from web.api.config import get_settings
def require_token(authorization: str | None = Header(default=None)) -> None:
token = get_settings().api_token
if not token:
return # auth disabled (no token configured) — dev only
if authorization != f"Bearer {token}":
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="invalid or missing token",
)