Repository navigation
fix(auth): propagate top-level universe_domain in impersonated creds - #19221
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces validation and parsing of the service_account_impersonation_url within impersonated_credentials.py to extract the target principal, hostname, and universe domain, while ensuring they align with the configured universe domain. It also adds extensive unit tests to verify various URL formats and validation errors. The feedback suggests stripping trailing dots from the resolved explicit universe domain to prevent validation failures when comparing it against the stripped URL host.
ohmayr
force-pushed
the
fix/auth-impersonated-url-host
branch
from
November 25, 2026 23:07
5ce410a to
0ca93b8
Compare
ohmayr
force-pushed
the
fix/auth-impersonated-url-host
branch
from
November 25, 2026 23:18
0ca93b8 to
5d9a79e
Compare
ohmayr
force-pushed
the
fix/auth-impersonated-url-host
branch
2 times, most recently
from
November 25, 2026 23:40
33f6123 to
eb7d546
Compare
ohmayr
force-pushed
the
fix/auth-impersonated-url-host
branch
from
November 25, 2026 23:51
eb7d546 to
b2f625b
Compare
ohmayr
force-pushed
the
fix/auth-impersonated-url-host
branch
2 times, most recently
from
November 27, 2026 15:35
23d5ec1 to
f5a7368
Compare
parthea
force-pushed
the
fix/auth-impersonated-url-host
branch
from
November 27, 2026 15:48
f5a7368 to
6212227
Compare
ohmayr
force-pushed
the
fix/auth-impersonated-url-host
branch
from
November 27, 2026 15:50
6212227 to
c2e3ae7
Compare
Base automatically changed from
fix/auth-impersonated-top-level-universe
to
main
November 27, 2026 16:04
parthea
force-pushed
the
fix/auth-impersonated-url-host
branch
from
November 27, 2026 16:04
c2e3ae7 to
00ac5bb
Compare
ohmayr
marked this pull request as ready for review
November 27, 2026 16:07
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. Add an optional universe_domain parameter to Credentials.__init__() (validated via _helpers.validate_universe_domain() and compared against source_credentials.universe_domain via _helpers.compare_universe_domains()), forward it in _make_copy(), and propagate top-level universe_domain into a shallow copy of source_credentials_info in from_impersonated_service_account_info() without mutating caller input. b/589828921
ohmayr
force-pushed
the
fix/auth-impersonated-url-host
branch
from
November 30, 2026 20:09
00ac5bb to
7a30b38
Compare
parthea
reviewed
Nov 30, 2026
parthea
left a comment
Contributor
There was a problem hiding this comment.
Note: The review comments below are AI-generated.
Validate source_credentials.universe_domain in Credentials.__init__ even when universe_domain is omitted, defaulting explicit None or missing attributes to DEFAULT_UNIVERSE_DOMAIN without coercing empty strings. Validate nested source_credentials["universe_domain"] in from_impersonated_service_account_info before constructing source credentials, document the early universe_domain validation check, and add external_account_authorized_user propagation test coverage.
parthea
approved these changes
Nov 30, 2026
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
impersonated_credentials.Credentials.from_impersonated_service_account_info()ignored a top-leveluniverse_domainfield and delegated_universe_domainsolely tosource_credentials. Whensource_credentialsomitteduniverse_domain, impersonated credentials defaulted togoogleapis.comand sent source tokens toiamcredentials.googleapis.com.Summary of Changes
universe_domainparameter toimpersonated_credentials.Credentials.__init__()inpackages/google-auth/google/auth/impersonated_credentials.py(validated via_helpers.validate_universe_domain()and compared againstsource_credentials.universe_domainvia_helpers.compare_universe_domains()from chore(auth): add compare_universe_domains helper in _helpers #19220) and forward it in_make_copy().universe_domaininto a shallow copy ofsource_credentials_infoinfrom_impersonated_service_account_info()when the nested source config omits it, without mutating caller input.packages/google-auth/tests/test_impersonated_credentials.py.Verification
ruff check,ruff check --select I,ruff format --check, andmypy --config-file=../../mypy.inipassed with zero issues.pytestpassed (470 passed) with 100% statement and branch coverage ongoogle/auth/impersonated_credentials.py.b/589828921