-
-
Notifications
You must be signed in to change notification settings - Fork 695
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
PyJWKSet exposes an iterator but you cannot iterate it. #1024
Labels
Comments
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days |
pachewise
added a commit
to pachewise/pyjwt
that referenced
this issue
Feb 23, 2025
opened a draft PR for this, it seems straightforward but not sure if the maintainers want this functinality, or if they have some concerns |
auvipy
pushed a commit
that referenced
this issue
Feb 26, 2025
* Feat #1024: Add iterator for PyJWKSet * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix mypy type * changelog --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, in #724
__getitem__
was introduced which allowsjwkset['my key id']
which is great!However one cannot do e.g.
keys_using_hmac = [k for k in jwkset if ...]
or any other form of iteration.I believe
__iter__
needs to be implemented as python will treat any class with__getitem__
as iterable.Expected Result
Example use-case: this should print all the
kid
sActual Result
KeyError: keyset has no key for kid: 0
Reproduction Steps
System Information
Can provide if required, I don't think anything more than pyjwt 2.10.0 is relevant as the code in the aforementioned issue is agnostic to the rest.
Proposed resolution
I'm no python expert, but from the docs and the below example, I believe implementing
__iter__
is all that is required.I have confirmed this code resolves the error
I could make a PR later today but I am sure an existing collaborator would be able to get it into a release sooner.
The text was updated successfully, but these errors were encountered: