mirror of
https://github.com/sstent/AICyclingCoach.git
synced 2026-01-26 00:52:07 +00:00
11 lines
412 B
Python
11 lines
412 B
Python
from fastapi import HTTPException, Header, status
|
|
import os
|
|
|
|
async def verify_api_key(api_key: str = Header(..., alias="X-API-Key")):
|
|
"""Dependency to verify API key header"""
|
|
expected_key = os.getenv("API_KEY")
|
|
if not expected_key or api_key != expected_key:
|
|
raise HTTPException(
|
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
detail="Invalid or missing API Key"
|
|
) |