pro-search-api / utils /auth_x.py
vhr1007
x_api_key
88bbe7d
raw
history blame
459 Bytes
from fastapi import Header, HTTPException
import os
import logging
from config import X_API_KEY
def x_api_key_auth(x_api_key: str = Header(...)):
logging.info("Validating x-api-key")
#api_key = os.getenv('X_API_KEY')
expected_api_key = X_API_KEY # Replace with your actual API key
if x_api_key != expected_api_key:
raise HTTPException(status_code=401, detail="Invalid API Key")
logging.info("x-api-key is valid")
return True