-
-
Notifications
You must be signed in to change notification settings - Fork 700
PyJWT async #956
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
base: master
Are you sure you want to change the base?
PyJWT async #956
Conversation
for more information, see https://pre-commit.ci
apologies on the pre-commit failure, it wasn't working on my end for some reason so I pushed with 🤞 . I'll fix that. And of course, there is no test coverage - but I didn't want to make a deeper investment until I got some feedback. |
fixed (but still a lot of tests pending your response @jpadilla ) |
I'm not active on the project, I'm only here to say that YES, i'd love to have this change, I was looking for this functionality today and found this PR, would love to see this included. |
xD |
Any update on this? |
I could really use this too, I think @padrepitufo would make changes if/when there was any traction on this PR from @jpadilla |
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.
Pull Request Overview
This PR adds asynchronous support to PyJWT’s JWKS client to mitigate blocking behavior when fetching and processing signing keys. Key changes include:
- Introduction of asynchronous methods (fetch_data_async, get_jwk_set_async, get_signing_keys_async, get_signing_key_async, get_signing_key_from_jwt_async) in jwt/jwks_client.py.
- New async test cases and context manager (mocked_success_response_async) in tests/test_jwks_client.py.
- Minor updates such as version bump to 2.9.0 and inclusion of PyJWKAsyncDisabledError in jwt/exceptions.py.
Reviewed Changes
Copilot reviewed 5 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/test_jwks_client.py | Added async context manager and async test for get_signing_key_from_jwt_async. |
pyproject.toml | Updated to ignore .tool-versions in manifest checks. |
jwt/jwks_client.py | Added async versions of data fetching and signing key retrieval methods. |
jwt/exceptions.py | Added a new exception (PyJWKAsyncDisabledError). |
jwt/init.py | Bumped version from 2.8.0 to 2.9.0. |
Files not reviewed (3)
- .tool-versions: Language not supported
- docs/usage.rst: Language not supported
- setup.cfg: Language not supported
Co-authored-by: Copilot <[email protected]>
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.
please, fix the merge conflicts and make the CI green for better review
I am somewhat new to contributing to a python library, and I am not sure if the code I'm supplying is needed/wanted-by/appropriate-for this project. If there is already a suggested way to use PyJWT within an asynchronous context (like FastAPI) I would like guidance. If something like this could be useful I can add tests or make changes to align the code with the style of the project.
The purpose of this PR is to mitigate blocking code/calls such as represented in this tutorial (to
get_signing_key_from_jwt
):I wish to call it like so
Thank you in advance for any guidance/direction you provide.