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

New API: Retrieving a key by KID from a PyJWKSet? #724

Closed
woodruffw opened this issue Jan 21, 2022 · 1 comment · Fixed by #725
Closed

New API: Retrieving a key by KID from a PyJWKSet? #724

woodruffw opened this issue Jan 21, 2022 · 1 comment · Fixed by #725

Comments

@woodruffw
Copy link
Contributor

woodruffw commented Jan 21, 2022

First of all, thanks for creating and maintaining this library!

The current PyJWKSet API is pretty thin: it wraps a list of PyJWK and provides basic deserialization, but nothing else.

I'd like to propose adding PyJWKSet.__getitem__, which would allow a user to index the PyJWKSet by key ID and return the corresponding PyJWK (or KeyError if not present). This saves users from having to write their own search over the PyJWKSet, and doesn't significantly complicate the current API.

With __getitem__, the use pattern would be:

jwks = PyJWKSet(keys)
jwk = jwks["somelonghexkeyid"]

Would this functionality be welcome? If so, I am happy to contribute it.

woodruffw added a commit to woodruffw-forks/pyjwt that referenced this issue Jan 21, 2022
@woodruffw
Copy link
Contributor Author

I went ahead and opened #725 with the changes, since they're pretty small.

auvipy pushed a commit that referenced this issue Jan 25, 2022
* api_jwk: Add PyJWKSet.__getitem__

Closes #724.

* CHANGELOG: record changes
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 a pull request may close this issue.

1 participant