Skip to content

Commit

Permalink
πŸ›βœ… introduce leeway of 1s for jwt.decode
Browse files Browse the repository at this point in the history
This addresses breaking change in `pyjwt` version 2.6 (jpadilla/pyjwt#797), where validation will now raise an `ImmatureSignatureError` if the 'issued at' time is in the future, with default 0 leeway.

Integration tests fail with `pyjwt~=2.6`, potentially because of clock synchronization / network latency between `issued_at` time at generation and decoding of the jwt; so, a leeway of 1 second accommodates any potential latency / clock sync issue

Signed-off-by: ff137 <ff137@proton.me>
  • Loading branch information
ff137 committed Jul 24, 2023
1 parent cebcbd6 commit 9f66f09
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aries_cloudagent/multitenant/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ async def create_auth_token(
def get_wallet_details_from_token(self, token: str) -> Tuple[str, str]:
"""Get the wallet_id and wallet_key from provided token."""
jwt_secret = self._profile.context.settings.get("multitenant.jwt_secret")
token_body = jwt.decode(token, jwt_secret, algorithms=["HS256"], leeway=5)
token_body = jwt.decode(token, jwt_secret, algorithms=["HS256"], leeway=1)
wallet_id = token_body.get("wallet_id")
wallet_key = token_body.get("wallet_key")
return wallet_id, wallet_key
Expand Down Expand Up @@ -360,7 +360,7 @@ async def get_profile_for_token(
jwt_secret = self._profile.context.settings.get("multitenant.jwt_secret")
extra_settings = {}

token_body = jwt.decode(token, jwt_secret, algorithms=["HS256"], leeway=5)
token_body = jwt.decode(token, jwt_secret, algorithms=["HS256"], leeway=1)

wallet_id = token_body.get("wallet_id")
wallet_key = token_body.get("wallet_key")
Expand Down

0 comments on commit 9f66f09

Please sign in to comment.