Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions descope/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,11 +637,17 @@ def _validate_token(
audience=audience,
leeway=self.jwt_validation_leeway,
)
except (ImmatureSignatureError, ExpiredSignatureError):
except (ImmatureSignatureError):
raise AuthException(
400,
ERROR_TYPE_INVALID_TOKEN,
"Received Invalid token times error due to time glitch (between machines) during jwt validation, try to set the jwt_validation_leeway parameter (in DescopeClient) to higher value than 5sec which is the default",
"Received Invalid token (nbf in future) during jwt validation. Error can be due to time glitch (between machines), try to set the jwt_validation_leeway parameter (in DescopeClient) to higher value than 5sec which is the default",
)
except (ExpiredSignatureError):
raise AuthException(
401,
ERROR_TYPE_INVALID_TOKEN,
"Received expired token (exp in past) during jwt validation. (sometimes can be due to time glitch (between machines), try to set the jwt_validation_leeway parameter (in DescopeClient) to higher value than 5sec which is the default)",
)

claims["jwt"] = token
Expand Down
2 changes: 1 addition & 1 deletion tests/test_descope_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ def test_jwt_validation_leeway(self):
self.assertEqual(cm.exception.status_code, 400)
self.assertEqual(
cm.exception.error_message,
"Received Invalid token times error due to time glitch (between machines) during jwt validation, try to set the jwt_validation_leeway parameter (in DescopeClient) to higher value than 5sec which is the default",
"Received Invalid token (nbf in future) during jwt validation. Error can be due to time glitch (between machines), try to set the jwt_validation_leeway parameter (in DescopeClient) to higher value than 5sec which is the default",
)

def test_select_tenant(self):
Expand Down
Loading