19 lines
560 B
Python
19 lines
560 B
Python
from __future__ import annotations
|
|
|
|
from typing import Annotated, Optional
|
|
|
|
from fastapi import Depends, Header, HTTPException
|
|
|
|
from app.settings import Settings, get_settings
|
|
|
|
|
|
def require_ingest_auth(
|
|
settings: Annotated[Settings, Depends(get_settings)],
|
|
x_api_key: Annotated[Optional[str], Header(alias="X-API-Key")] = None,
|
|
) -> None:
|
|
expected = settings.ingest_api_key.strip()
|
|
if not expected:
|
|
return
|
|
if (x_api_key or "").strip() != expected:
|
|
raise HTTPException(status_code=401, detail="Invalid or missing X-API-Key")
|