From a4d36bb042f6927bd58b767f2b3a7ceb2f06289e Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Thu, 14 Dec 2023 17:27:48 +0100 Subject: [PATCH] Log warnings in jwt error handlers --- qwc_services_core/jwt.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qwc_services_core/jwt.py b/qwc_services_core/jwt.py index 2ee14b7..72bd866 100644 --- a/qwc_services_core/jwt.py +++ b/qwc_services_core/jwt.py @@ -49,6 +49,7 @@ def restplus_error_handler(error): @jwt.expired_token_loader def handle_expired_token(jwtheader, jwtdata): # Unset cookies and redirect to requested page on expired token + app.logger.warn("Expired token: %s" % str(err)) resp = redirect(request.url) unset_jwt_cookies(resp) return resp @@ -56,6 +57,7 @@ def handle_expired_token(jwtheader, jwtdata): @jwt.invalid_token_loader def handle_invalid_token(err): # Unset cookies and redirect to requested page on token error + app.logger.warn("Invalid token: %s" % str(err)) resp = redirect(request.url) unset_jwt_cookies(resp) return resp @@ -63,6 +65,7 @@ def handle_invalid_token(err): @jwt.unauthorized_loader def unauthorized(err): # Redirect to requested page on authorized error (i.e. CSRF token error) + app.logger.warn("Unauthorized: %s" % str(err)) return redirect(request.url) return jwt