Skip to content
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

Merged
merged 5 commits into from
Jul 17, 2024

Conversation

bgier-stytch
Copy link
Contributor

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.

@bgier-stytch bgier-stytch marked this pull request as ready for review July 16, 2024 21:22
@bgier-stytch bgier-stytch requested a review from a team as a code owner July 16, 2024 21:22
@@ -1 +1 @@
__version__ = "10.1.0"
__version__ = "11.0.0"
Copy link
Contributor Author

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.

Copy link
Contributor

@logan-stytch logan-stytch left a 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,
Copy link
Contributor

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

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated comment?

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(
Copy link
Contributor

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:
Copy link
Contributor

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!

@bgier-stytch bgier-stytch merged commit a584134 into main Jul 17, 2024
6 checks passed
@bgier-stytch bgier-stytch deleted the oback-290 branch July 17, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants