-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OBACK-290: Fix issue with python Authenticate JWT locally logic #209
Conversation
@@ -1 +1 @@ | |||
__version__ = "10.1.0" | |||
__version__ = "11.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're changing the return type of Authenticate this should be a major version bump.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple really small codegen comments but this looks great! Thank you!
@@ -258,7 +259,7 @@ def authenticate_jwt( | |||
session_jwt: str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't comment any higher, but # ADDIMPORT: from stytch.consumer.models.sessions import AuthenticateJWTLocalResponse
or it'll get removed the next time codegen runs
stytch/consumer/api/sessions.py
Outdated
self.authenticate_jwt_local( | ||
session_jwt=session_jwt, | ||
max_token_age_seconds=max_token_age_seconds, | ||
# Return the local_result if available, otherwise call the Stytch API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated comment?
stytch/consumer/api/sessions.py
Outdated
session_jwt=session_jwt, | ||
max_token_age_seconds=max_token_age_seconds, | ||
# Return the local_result if available, otherwise call the Stytch API | ||
local_token = self.authenticate_jwt_local( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[dust] local_resp
or local_res
feels like a better name than local_token
@@ -232,6 +234,23 @@ def test_webauthn(self) -> None: | |||
# TODO: No test public key credential (see skipTest above) | |||
self.assertTrue(api.authenticate(public_key_credential="").is_success) | |||
|
|||
def test_authenticate(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet! Thanks for adding a test!
This fixes an issue related to how pyJWT handles verifications. The verification logic raises Exceptions in the event that data is bad (such as an expired token being too old), which was breaking our function's ability to call the underlying authenticate endpoint and receive a new JWT token.
We now except this exception and return None, which then calls our underlying authenticate endpoint to grab a new JWT.
This change also updates our response type for this endpoint to return a dedicated type here, which is more in line with how Node handles it.