General-API/src/dependencies.py

8 lines
278 B
Python

from typing import Annotated
from fastapi import Header, HTTPException
import config
async def get_token_header(x_token: Annotated[str, Header()]):
if x_token != config.getConfig()["api-key"]
raise HTTPException(status_code=400, detail="X-Token header is invalid")