Spaces:
Paused
Paused
| 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", | |
| ) |