Spaces:
Sleeping
Sleeping
Download auth.py from brocode12/bell-backend: direct link, hf CLI and curl.
- Browser
- Download file 457 Bytes
-
https://huggingface.co/spaces/brocode12/bell-backend/resolve/main/auth.py
- Command line
-
hf download hf://spaces/brocode12/bell-backend/auth.py
-
curl -L -o auth.py https://huggingface.co/spaces/brocode12/bell-backend/resolve/main/auth.py
457 Bytes
| """Bearer-token guard for Bolna-facing tool endpoints.""" | |
| from fastapi import Header, HTTPException | |
| import config | |
| async def require_token(authorization: str = Header(default="")) -> None: | |
| if not config.BACKEND_API_TOKEN: | |
| return # auth disabled (local dev) | |
| token = authorization.removeprefix("Bearer ").strip() | |
| if token != config.BACKEND_API_TOKEN: | |
| raise HTTPException(status_code=401, detail="Invalid or missing API token") | |