mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
14 lines
495 B
Python
14 lines
495 B
Python
from fastapi import Depends, HTTPException, status
|
|
from fastapi.security import APIKeyHeader
|
|
from app.config import get_settings
|
|
|
|
|
|
api_key_header = APIKeyHeader(name=get_settings().API_KEY_NAME, auto_error=False)
|
|
|
|
|
|
async def validate_api_key(api_key_header: str = Depends(api_key_header)):
|
|
if api_key_header != get_settings().API_KEY:
|
|
raise HTTPException(
|
|
status_code=status.HTTP_403_FORBIDDEN, detail="Could not validate credentials"
|
|
)
|
|
return api_key_header
|