Skip to content

Fix authenticate_jwt_async() to be non-blocking#309

Merged
logan-stytch merged 8 commits intomainfrom
jlai/auth_jwt_local_async_fix
Mar 19, 2026
Merged

Fix authenticate_jwt_async() to be non-blocking#309
logan-stytch merged 8 commits intomainfrom
jlai/auth_jwt_local_async_fix

Conversation

@jlai-stytch
Copy link
Contributor

@jlai-stytch jlai-stytch commented Mar 19, 2026

Description

Both Consumer and B2B authenticate_jwt_async() methods aren't fully asynchronous, so it can be blocking

The Consumer one doesn't use an async version of the helper authenticate_jwt_local() method, whereas the B2B one does:

local_token = self.authenticate_jwt_local(

local_session = await self.authenticate_jwt_local_async(

Both Consumer and B2B also call PyJWT's underlying get_signing_key_from_jwt() method, which is synchronous. The library doesn't seem to support fetching JWKS async: jpadilla/pyjwt#1120

This attempts to fix both these issues

Also renames local_token -> local_session because that makes more sense

Unit tests added are vibe coded

Motivation

Community bug report https://app.plain.com/workspace/w_01HAQ5N757DAG0R7JTXZ4MQYKY/thread/th_01KM1BBWC7PMGA2SRS6C9KQQN3/

Testing

  • TBD

@logan-stytch logan-stytch force-pushed the jlai/auth_jwt_local_async_fix branch from ebab734 to 0c73a7f Compare March 19, 2026 16:05
@jlai-stytch jlai-stytch changed the title Make Consumer authenticate_jwt_async() call helper asynchronously Fix authenticate_jwt_async() to be non-blocking Mar 19, 2026
@logan-stytch logan-stytch marked this pull request as ready for review March 19, 2026 17:29
@logan-stytch logan-stytch requested a review from a team as a code owner March 19, 2026 17:29
@logan-stytch logan-stytch merged commit b7c8062 into main Mar 19, 2026
14 checks passed
@logan-stytch logan-stytch deleted the jlai/auth_jwt_local_async_fix branch March 19, 2026 17:35
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