dashboard-nanobot/dashboard-edge/app/dependencies/auth.py

15 lines
488 B
Python

from fastapi import Header, HTTPException
from app.core.settings import EDGE_AUTH_TOKEN
EDGE_AUTH_HEADER = "x-dashboard-edge-token"
def require_edge_auth(x_dashboard_edge_token: str | None = Header(default=None)) -> None:
configured = str(EDGE_AUTH_TOKEN or "").strip()
if not configured:
return
supplied = str(x_dashboard_edge_token or "").strip()
if supplied != configured:
raise HTTPException(status_code=401, detail="Invalid dashboard-edge token")