from __future__ import annotations from typing import Optional from fastapi import Depends, Header, HTTPException from app.settings import Settings, get_settings def require_ingest_auth( settings: Settings = Depends(get_settings), x_api_key: Optional[str] = Header(None, alias="X-API-Key"), ) -> 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")