Skip to content

fix(auth): enforce self-signed JWT rules for non-default universe in service_account refresh - #19279

Open
parthea wants to merge 1 commit into
mainfrom
fix/auth-sa-non-gdu-refresh
Open

parthea wants to merge 1 commit into
mainfrom
fix/auth-sa-non-gdu-refresh

Conversation

@parthea

@parthea parthea commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix service_account.Credentials.__init__ to compare self._universe_domain (rather than the raw universe_domain argument) against DEFAULT_UNIVERSE_DOMAIN so universe_domain=None does not inadvertently enable _always_use_jwt_access.
  • Extract _try_refresh_self_signed_jwt() on service_account.Credentials and raise RefreshError when refreshing non-default universe credentials without scopes or an audience, instead of falling through to the OAuth 2.0 assertion grant.
  • Reuse _try_refresh_self_signed_jwt() in _service_account_async.Credentials.refresh() so async service account credentials match the sync self-signed JWT and non-default universe refresh behavior.

@parthea
parthea requested review from a team as code owners November 30, 2026 21:22

@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 aligns the asynchronous service account credentials refresh logic with the synchronous implementation by attempting to refresh self-signed JWT credentials before falling back to the OAuth 2.0 assertion grant. It extracts this logic into a helper method, fixes an initialization bug where the local variable was checked instead of the instance variable, and adds comprehensive unit tests for both synchronous and asynchronous flows. There are no review comments to address, so I have no additional feedback to provide.

This branch has not been deployed

No deployments
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