diff options
author | Parker <contact@pkrm.dev> | 2024-06-24 16:24:09 -0500 |
---|---|---|
committer | Parker <contact@pkrm.dev> | 2024-06-24 16:24:09 -0500 |
commit | 5b92454760a8af14bd1031e72024946f868d1de6 (patch) | |
tree | f8384cbf0d142777d9bff341e13fd5882182908b /app/check_api_key.py | |
parent | 80a39d38bf829193c655a7320c86df2a3146db2a (diff) |
Major overhaul + Bare bones web UI
Diffstat (limited to 'app/check_api_key.py')
-rw-r--r-- | app/check_api_key.py | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/app/check_api_key.py b/app/check_api_key.py deleted file mode 100644 index d8b92f4..0000000 --- a/app/check_api_key.py +++ /dev/null @@ -1,22 +0,0 @@ -import fastapi -from fastapi import Security, HTTPException -from fastapi.security import APIKeyHeader -import sqlalchemy - -from db import engine - -""" -Make sure the provided API key is valid -""" -api_key_header = APIKeyHeader(name="X-API-Key") - -def check_api_key(api_key_header: str = Security(api_key_header)) -> str: - with engine.begin() as conn: - response = conn.execute(sqlalchemy.text("SELECT api_key FROM keys WHERE api_key = :api_key"), {'api_key': api_key_header}).fetchone() - if response: - return response[0] - else: - raise HTTPException( - status_code=fastapi.status.HTTP_401_UNAUTHORIZED, - detail="Invalid or missing API key" - ) |