From 0722a26fb383227d94a7e9254d43e51e58c107c4 Mon Sep 17 00:00:00 2001 From: profitroll Date: Thu, 16 Feb 2023 14:54:29 +0100 Subject: [PATCH] Removed deprecated shit --- modules/app.py | 52 -------------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/modules/app.py b/modules/app.py index 4bdc062..e567d93 100644 --- a/modules/app.py +++ b/modules/app.py @@ -10,58 +10,6 @@ from modules.utils import configGet, jsonLoad app = FastAPI(title="END PLAY Photos", docs_url=None, redoc_url=None, version="0.1") -api_key_query = APIKeyQuery(name="apikey", auto_error=False) -api_key_header = APIKeyHeader(name="apikey", auto_error=False) -api_key_cookie = APIKeyCookie(name="apikey", auto_error=False) - - -def get_all_api_keys(): - return jsonLoad(f'{configGet("data_location")}{sep}api_keys.json') - -def get_all_expired_keys(): - return jsonLoad(f'{configGet("data_location")}{sep}expired_keys.json') - -def check_project_key(project: str, apikey: APIKey) -> bool: - keys = jsonLoad(f'{configGet("data_location")}{sep}api_keys.json') - if apikey in keys: - if keys[apikey] != []: - if project in keys[apikey]: - return True - else: - return False - else: - return False - else: - return False - - -async def get_api_key( - api_key_query: str = Security(api_key_query), - api_key_header: str = Security(api_key_header), - api_key_cookie: str = Security(api_key_cookie), -): - - keys = get_all_api_keys() - expired = get_all_expired_keys() - - def is_valid(key): - if (key in keys) or (key == "publickey"): - return True - else: - return False - - if is_valid(api_key_query): - return api_key_query - elif is_valid(api_key_header): - return api_key_header - elif is_valid(api_key_cookie): - return api_key_cookie - else: - if (api_key_query in expired) or (api_key_header in expired) or (api_key_cookie in expired): - raise HTTPException(status_code=HTTP_403_FORBIDDEN, detail=configGet("key_expired", "messages")) - else: - raise HTTPException(status_code=HTTP_401_UNAUTHORIZED, detail=configGet("key_invalid", "messages")) - @app.get("/docs", include_in_schema=False) async def custom_swagger_ui_html(): return get_swagger_ui_html(