Skip to content

fix(oauth2): avoid redundant JWKS network fetches#17891

Open
macastelaz wants to merge 3 commits into
mainfrom
fix-jwks-double-fetch
Open

fix(oauth2): avoid redundant JWKS network fetches#17891
macastelaz wants to merge 3 commits into
mainfrom
fix-jwks-double-fetch

Conversation

@macastelaz

Copy link
Copy Markdown
Contributor

Addresses a performance regression resulting in duplicate fetches of the JWKS endpoint by utilizing the already-fetched certs payload via PyJWKSet.from_dict instead of deferring to PyJWKClient.

@macastelaz
macastelaz requested review from a team as code owners July 24, 2026 02:11

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the ID token verification to use PyJWKSet.from_dict and get_unverified_header from pyjwt instead of PyJWKClient. However, PyJWKSet does not support subscripting, which will cause a runtime TypeError when attempting to retrieve the signing key. The reviewer recommends iterating over jwkset.keys to find the matching key ID and updating the corresponding unit tests to mock this behavior.

Comment thread packages/google-auth/google/oauth2/id_token.py Outdated
Comment thread packages/google-auth/tests/oauth2/test_id_token.py
@macastelaz
macastelaz force-pushed the fix-jwks-double-fetch branch from a1155ce to 1b7f57a Compare July 24, 2026 02:17
Addresses a performance regression resulting in duplicate fetches of the JWKS endpoint by utilizing the already-fetched certs payload via PyJWKSet.from_dict instead of deferring to PyJWKClient.
@macastelaz
macastelaz force-pushed the fix-jwks-double-fetch branch from 1b7f57a to 0087e24 Compare July 24, 2026 02:24
@macastelaz
macastelaz requested a review from a team as a code owner July 24, 2026 02:29
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.

1 participant