From 3c245d86710fa1d17713c0d3b254194960d370d4 Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 18 Jan 2023 14:31:22 +0100 Subject: [PATCH] Removed trash and optimized imports --- modules/app.py | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/modules/app.py b/modules/app.py index 59b4618..15bf194 100644 --- a/modules/app.py +++ b/modules/app.py @@ -1,4 +1,3 @@ -from os import path from typing import Union from fastapi import FastAPI, Security, HTTPException from starlette.status import HTTP_401_UNAUTHORIZED, HTTP_403_FORBIDDEN @@ -6,7 +5,7 @@ from fastapi.security import APIKeyQuery, APIKeyHeader, APIKeyCookie from fastapi.openapi.models import APIKey from fastapi.openapi.docs import get_swagger_ui_html, get_redoc_html from starlette.status import HTTP_401_UNAUTHORIZED -from modules.utils import configGet, jsonLoad +from modules.utils import configGet from modules.security import passEncode from modules.database import col_apikeys, col_expired @@ -17,26 +16,6 @@ api_key_header = APIKeyHeader(name="apikey", auto_error=False) api_key_cookie = APIKeyCookie(name="apikey", auto_error=False) -def get_all_api_keys() -> list: - return jsonLoad(path.join(configGet("data", "locations"), "api_keys.json")) - -def get_all_expired_keys() -> list: - return jsonLoad(path.join(configGet("data", "locations"), "expired_keys.json")) - -# def check_project_key(project: str, apikey: APIKey) -> bool: -# keys = jsonLoad(path.join(configGet("data", "locations"), "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), @@ -62,6 +41,7 @@ def user_by_key(apikey: Union[str, APIKey]) -> Union[str, None]: db_key = col_apikeys.find_one({"hash": passEncode(apikey)}) return db_key["user"] if db_key is not None else None + @app.get("/docs", include_in_schema=False) async def custom_swagger_ui_html(): return get_swagger_ui_html(