Initial commit: FishServer monorepo (FishAction, FishMeasure, fish_api)
Made-with: Cursor
This commit is contained in:
18
fish_api/app/deps.py
Normal file
18
fish_api/app/deps.py
Normal file
@@ -0,0 +1,18 @@
|
||||
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")
|
||||
Reference in New Issue
Block a user