Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Fixed

- Annotate PyJWKSet.keys for pyright by @tamird in `#1134 <https://github.com/jpadilla/pyjwt/pull/1134>`__
- Close ``HTTPError`` response to prevent ``ResourceWarning`` on Python 3.14 by @veeceey in `#1133 <https://github.com/jpadilla/pyjwt/pull/1133>`__
- Do not keep `algorithms` dict in JWK instances by @akx in `#1143 <https://github.com/jpadilla/pyjwt/pull/1143>`__
Comment thread
auvipy marked this conversation as resolved.
Outdated

Added
~~~~~
Expand Down
11 changes: 6 additions & 5 deletions jwt/api_jwk.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def __init__(self, jwk_data: JWKDict, algorithm: str | None = None) -> None:
:raises MissingCryptographyError: If the algorithm requires ``cryptography`` to be installed and it is not available.
:raises PyJWKError: If unable to find an algorithm for the key.
"""
self._algorithms = get_default_algorithms()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is this change backward compatible?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's a _private attribute.

self._jwk_data = jwk_data

kty = self._jwk_data.get("kty", None)
Expand Down Expand Up @@ -73,10 +72,12 @@ def __init__(self, jwk_data: JWKDict, algorithm: str | None = None) -> None:

self.algorithm_name = algorithm

if algorithm in self._algorithms:
self.Algorithm = self._algorithms[algorithm]
else:
raise PyJWKError(f"Unable to find an algorithm for key: {self._jwk_data}")
try:
self.Algorithm = get_default_algorithms()[algorithm]
except KeyError:
raise PyJWKError(
f"Unable to find an algorithm for key: {self._jwk_data}",
) from None

self.key = self.Algorithm.from_jwk(self._jwk_data)

Expand Down