Skip to content

Commit

Permalink
Skip verification of JWT's iat claim
Browse files Browse the repository at this point in the history
Client clock skew can lead to invalid JWTs
resulting the the following error during login:

```
nextstrain.cli.aws.cognito.TokenError:
ImmatureSignatureError: The token is not yet valid (iat)
````

See <#307>
and the (internal) Slack thread
<https://bedfordlab.slack.com/archives/C01LCTT7JNN/p1719286802460679>
for discussion about whether iat timestamps ahead of the current
clock are actually invalid JWTs.
  • Loading branch information
jameshadfield committed Aug 29, 2024
1 parent 36f8989 commit df7d035
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions nextstrain/cli/authn/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,8 @@ def verify_tokens(self, *, id_token, access_token, refresh_token):

def _verify_id_token(self, token):
"""
Verifies all aspects of the given ID *token* (a signed JWT).
Verifies all aspects of the given ID *token* (a signed JWT) except for the iat
(issued at claim, see <https://github.com/nextstrain/cli/issues/307>)
Assertions about expected algorithms, audience, issuer, and token use
follow guidelines from
Expand All @@ -656,7 +657,9 @@ def _verify_id_token(self, token):
algorithms = ["RS256"],
audience = self.client_configuration["client_id"],
issuer = self.openid_configuration["issuer"],
options = { "require": ["exp"] })
options = { "require": ["exp"],
"verify_iat": False,
})

except jwt.exceptions.ExpiredSignatureError:
raise ExpiredTokenError(use)
Expand Down

0 comments on commit df7d035

Please sign in to comment.