Repository navigation
chore(auth): add compare_universe_domains helper in _helpers - #19220
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for universe_domain in impersonated_credentials.py. It adds the universe_domain parameter to the Credentials constructor and the from_impersonated_service_account_info method, along with validation logic to ensure consistency between the impersonated and source credentials' universe domains. Corresponding unit tests have been added to verify these validation checks. There are no review comments to assess, and I have no feedback to provide.
ohmayr
force-pushed
the
fix/auth-impersonated-top-level-universe
branch
from
November 25, 2026 23:07
fba6668 to
79d9927
Compare
Base automatically changed from
refactor/auth-validate-universe-domain
to
main
November 25, 2026 23:18
ohmayr
force-pushed
the
fix/auth-impersonated-top-level-universe
branch
4 times, most recently
from
November 25, 2026 23:51
4adec48 to
53c324d
Compare
ohmayr
force-pushed
the
fix/auth-impersonated-top-level-universe
branch
from
November 25, 2026 23:55
53c324d to
f35db0b
Compare
ohmayr
marked this pull request as ready for review
November 25, 2026 23:57
parthea
reviewed
Nov 26, 2026
Contributor
|
I'm going to click the |
Wrapper credentials such as impersonated and downscoped credentials need a consistent helper to verify that a configured universe_domain matches an expected universe domain (for example, from wrapped source credentials or an endpoint host). Add _helpers.compare_universe_domains() next to _helpers.validate_universe_domain() along with unit tests. b/589828921
parthea
force-pushed
the
fix/auth-impersonated-top-level-universe
branch
from
November 27, 2026 15:48
072fbe1 to
9fc0026
Compare
parthea
approved these changes
Nov 27, 2026
parthea
enabled stacked auto-merge (squash)
November 27, 2026 15:53
ohmayr
added a commit
that referenced
this pull request
Nov 30, 2026
…19221) ## Context & Problem `impersonated_credentials.Credentials.from_impersonated_service_account_info()` ignored a top-level `universe_domain` field and delegated `_universe_domain` solely to `source_credentials`. When `source_credentials` omitted `universe_domain`, impersonated credentials defaulted to `googleapis.com` and sent source tokens to `iamcredentials.googleapis.com`. ## Summary of Changes - Add an optional `universe_domain` parameter to `impersonated_credentials.Credentials.__init__()` in `packages/google-auth/google/auth/impersonated_credentials.py` (validated via `_helpers.validate_universe_domain()` and compared against `source_credentials.universe_domain` via `_helpers.compare_universe_domains()` from #19220) and forward it in `_make_copy()`. - Propagate top-level `universe_domain` into a shallow copy of `source_credentials_info` in `from_impersonated_service_account_info()` when the nested source config omits it, without mutating caller input. - Add unit tests in `packages/google-auth/tests/test_impersonated_credentials.py`. ## Verification - `ruff check`, `ruff check --select I`, `ruff format --check`, and `mypy --config-file=../../mypy.ini` passed with zero issues. - `pytest` passed (470 passed) with 100% statement and branch coverage on `google/auth/impersonated_credentials.py`. b/589828921
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context & Problem
Wrapper credentials such as impersonated and downscoped credentials need a consistent helper in
google.auth._helpersto verify that a configureduniverse_domainmatches an expected universe domain (for example, from wrapped source credentials or an endpoint host).Summary of Changes
compare_universe_domains(universe_domain, expected_universe_domain)inpackages/google-auth/google/auth/_helpers.pyright aftervalidate_universe_domain().packages/google-auth/tests/test__helpers.py.Verification
ruff check,ruff check --select I,ruff format --check, andmypy --config-file=../../mypy.inipassed with zero issues.pytestpassed (131 passed) with 100% statement and branch coverage ongoogle/auth/_helpers.py.b/589828921