From ff8f5eae361ab02bf690ffcea2fef1885570346e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madis=20M=C3=A4gi?= Date: Wed, 2 Aug 2023 01:37:19 +0300 Subject: [PATCH] Fix empty api key handling --- inventory-app/api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inventory-app/api.py b/inventory-app/api.py index ebed82d..10241aa 100644 --- a/inventory-app/api.py +++ b/inventory-app/api.py @@ -15,6 +15,8 @@ def check_api_key(f): @wraps(f) def decorated_function(*args, **kwargs): request_key = request.headers.get('Authorization', False) + if not request_key: + return "nope", 403 found_key = re.search(r"Basic (.*)", request_key).group(1) if not found_key or found_key != api_key: return "nope", 403