From 8ae8c5c454ba42e8f56f415d33bbaaac7d1a37ec Mon Sep 17 00:00:00 2001 From: Parker Date: Mon, 4 Nov 2024 00:12:36 -0600 Subject: Remove API Keys -> Authenticate with JWT --- api/util/check_api_key.py | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 api/util/check_api_key.py (limited to 'api/util/check_api_key.py') diff --git a/api/util/check_api_key.py b/api/util/check_api_key.py deleted file mode 100644 index 9c4c22e..0000000 --- a/api/util/check_api_key.py +++ /dev/null @@ -1,21 +0,0 @@ -from fastapi import Security, HTTPException, Depends, status -from fastapi.security import APIKeyHeader - -from models import User -from api.util.db_dependency import get_db - -""" -Make sure the provided API key is valid, then return the user's ID -""" -api_key_header = APIKeyHeader(name="X-API-Key") - - -def check_api_key( - api_key_header: str = Security(api_key_header), db=Depends(get_db) -) -> str: - response = db.query(User).filter(User.api_key == api_key_header).first() - if not response: - raise HTTPException( - status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid API key" - ) - return {"value": api_key_header, "owner": response.id} -- cgit v1.2.3-70-g09d2