Spaces:
Sleeping

File size: 457 Bytes
a812c01
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
"""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")