From fa77ee26e4048d0404b053c3f593a705bcd65cbe Mon Sep 17 00:00:00 2001 From: Daniel Perrefort Date: Tue, 23 Jul 2024 13:20:14 -0400 Subject: [PATCH] Fixes bug in JWT parsing (#28) --- keystone_client/client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/keystone_client/client.py b/keystone_client/client.py index 236a3fe..54efb30 100644 --- a/keystone_client/client.py +++ b/keystone_client/client.py @@ -315,13 +315,13 @@ def login(self, username: str, password: str, timeout: int = default_timeout) -> response.raise_for_status() # Parse data from the refresh token - refresh_payload = jwt.decode(self._refresh_token) self._refresh_token = response.json().get("refresh") + refresh_payload = jwt.decode(self._refresh_token, options={"verify_signature": False}, algorithms='HS256') self._refresh_expiration = datetime.fromtimestamp(refresh_payload["exp"]) # Parse data from the access token - access_payload = jwt.decode(self._access_token) self._access_token = response.json().get("access") + access_payload = jwt.decode(self._access_token, options={"verify_signature": False}, algorithms='HS256') self._access_expiration = datetime.fromtimestamp(access_payload["exp"]) def logout(self, timeout: int = default_timeout) -> None: @@ -376,6 +376,7 @@ def _refresh_tokens(self, force: bool = True, timeout: int = default_timeout) -> ) response.raise_for_status() - refresh_payload = jwt.decode(self._refresh_token) self._refresh_token = response.json().get("refresh") + refresh_payload = jwt.decode(self._refresh_token, options={"verify_signature": False}, algorithms='HS256') self._refresh_expiration = datetime.fromtimestamp(refresh_payload["exp"]) +