setup assisant bot

This commit is contained in:
OwusuBlessing
2025-07-24 14:27:56 +01:00
commit 95d357de60
62 changed files with 1106 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
from fastapi import HTTPException, Depends, Security
from fastapi.security import APIKeyHeader
from api.models.requests import BaseRequest
from config import Config
api_key_header = APIKeyHeader(name="Authorization", auto_error=False)
async def get_api_key(api_key_header: str = Security(api_key_header)) -> str:
"""Validate API key from header"""
if not api_key_header or not api_key_header.startswith('Bearer '):
raise HTTPException(
status_code=401,
detail={"error": "Unauthorized", "message": "API key is missing or invalid."}
)
token = api_key_header.split(' ')[1]
if token != Config.API_KEY:
raise HTTPException(
status_code=401,
detail={"error": "Unauthorized", "message": "API key does not match."}
)
return token