Spaces:
Paused
Paused
Download app/core/auth.py from Fred808/Desk-Back2: direct link, hf CLI and curl.
- Browser
- Download file 614 Bytes
-
https://huggingface.co/spaces/Fred808/Desk-Back2/resolve/main/app/core/auth.py
- Command line
-
hf download hf://spaces/Fred808/Desk-Back2/app/core/auth.py
-
curl -L -o auth.py https://huggingface.co/spaces/Fred808/Desk-Back2/resolve/main/app/core/auth.py
614 Bytes
| from fastapi import Depends, HTTPException, status, Header | |
| from typing import Optional | |
| from .config import settings | |
| async def verify_service_token( | |
| x_service_token: Optional[str] = Header(None, alias="X-Service-Token") | |
| ) -> None: | |
| if not x_service_token: | |
| raise HTTPException( | |
| status_code=status.HTTP_401_UNAUTHORIZED, | |
| detail="X-Service-Token header is missing", | |
| ) | |
| if x_service_token != settings.SERVICE_TOKEN: | |
| raise HTTPException( | |
| status_code=status.HTTP_401_UNAUTHORIZED, | |
| detail="Invalid service token", | |
| ) |