From c6f0dd65e5bb5169b6024f9def83d0923b319961 Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 25 Apr 2024 12:19:45 -0400 Subject: [PATCH] log original error when token decoding fails w/ burnettk --- .../routes/authentication_controller.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/authentication_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/authentication_controller.py index ecc57f54..3461c67b 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/authentication_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/authentication_controller.py @@ -420,17 +420,18 @@ def _get_decoded_token(token: str) -> dict: try: decoded_token: dict = AuthenticationService.parse_jwt_token(_get_authentication_identifier_from_request(), token) except Exception as e: + current_app.logger.warning(f"Received exception when attempting to decode token: {e.__class__.__name__}: {str(e)}") AuthenticationService.set_user_has_logged_out() raise ApiError(error_code="invalid_token", message="Cannot decode token.", status_code=401) from e + + if "iss" in decoded_token: + return decoded_token else: - if "iss" in decoded_token: - return decoded_token - else: - current_app.logger.error(f"Unknown token type in get_decoded_token: token: {token}") - raise ApiError( - error_code="unknown_token", - message="Unknown token type in get_decoded_token", - ) + current_app.logger.error(f"Unknown token type in get_decoded_token: token: {token}") + raise ApiError( + error_code="unknown_token", + message="Unknown token type in get_decoded_token", + ) def _get_authentication_identifier_from_request() -> str: