ocr_backend / src /api /dependencies.py
ashu-choudhury's picture
Add 18 files
06bd65a verified
Raw
History Blame Contribute Delete
440 Bytes
from fastapi import Header, HTTPException, status
from src.config import settings
async def verify_api_key(x_api_key: str = Header(...)):
"""Validates the client's API Key against settings to prevent unauthorized usage."""
if x_api_key != settings.API_KEY:
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid or missing API key."
)
return x_api_key