From 5283b341c791e1279cd2008b725ae3427ae16326 Mon Sep 17 00:00:00 2001 From: msramalho <19508417+msramalho@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:04:40 +0000 Subject: [PATCH] minor change to security length check --- src/web/security.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/web/security.py b/src/web/security.py index b310782..bfa678a 100644 --- a/src/web/security.py +++ b/src/web/security.py @@ -15,10 +15,9 @@ def secure_compare(token, api_key): # Factory method to create an authentication dependency for a specific key def api_key_auth(api_key): + assert len(api_key) >= 20, "Invalid API key, must be at least 20 chars" async def auth(bearer: HTTPAuthorizationCredentials = Depends(bearer_security), auto_error=True): - assert len(api_key) >= 20, "Invalid API key, must be at least 20 chars" - is_correct = secure_compare(bearer.credentials, api_key) if is_correct: return True