From 9367f53bd59241c009c7824827ba13c1a2fbcdef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Mart=C3=ADnez=20S=C3=A1nchez?= Date: Sat, 11 Feb 2023 16:13:11 -0600 Subject: [PATCH] Update version and error handler for authorization header Now returns an JSON format for decode when authorization header is not available --- setup.cfg | 2 +- src/flask_authgen_jwt.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index cbb9ad8..1253202 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = Flask-authgen-jwt -version = 4.0.0 +version = 4.1.0 author = Diego Martinez license = MIT author_email = gd-code@outlook.com diff --git a/src/flask_authgen_jwt.py b/src/flask_authgen_jwt.py index 716a916..2c069d8 100644 --- a/src/flask_authgen_jwt.py +++ b/src/flask_authgen_jwt.py @@ -250,6 +250,8 @@ def __decode_jwt(self) -> Optional[dict]: :return: the decoded token or None if an error occurred """ auth_header = request.headers.get("Authorization") + if auth_header is None: + self.gen_abort_error("Authorization header is missing", 400) auth_header = auth_header.split(" ") token = auth_header[1] del auth_header