Repository navigation
Conversation
…loning and wrapping
There was a problem hiding this comment.
Code Review
This pull request refactors credential copying and universe domain handling across Compute Engine, Downscoped, and External Account credentials by introducing a centralized _copy_with helper. This preserves the unformatted token_url template and ensures that Regional Access Boundary (RAB) state is reset when switching to a non-default universe domain. Feedback on these changes highlights a potential TypeError in external_account.py if self._universe_domain is None during token URL formatting, suggesting the use of the self.universe_domain property instead. Additionally, it is recommended to use domain comparison utilities rather than manual .lower() checks in compute_engine/credentials.py to safely handle missing attributes.
Summary of Changes
external_account.Credentials(packages/google-auth/google/auth/external_account.py):credentials.CredentialsWithUniverseDomain.self._universe_domaintoDEFAULT_UNIVERSE_DOMAINwhenuniverse_domain=Noneis passed explicitly.token_urltemplate in_raw_token_urlacross cloning (_copy_with,_make_copy,with_scopes,with_quota_project,with_token_uri, andwith_universe_domain) and rebuild_token_url,_cloud_resource_manager_url, and_sts_clientwhen cloning with a newuniverse_domainortoken_uri.universe_domaininwith_universe_domain()via_helpers.validate_universe_domain()._rab_managerstate when the cloned credentials targetDEFAULT_UNIVERSE_DOMAIN.external_account_authorized_user.Credentials(packages/google-auth/google/auth/external_account_authorized_user.py):credentials.CredentialsWithUniverseDomain._raw_token_urland format{universe_domain}templates intoken_url, rebuilding_sts_clientinwith_token_uri()andwith_universe_domain().universe_domaininwith_universe_domain()via_helpers.validate_universe_domain().tokenandexpirywhen cloning to a different universe domain._rab_managerstate when the cloned credentials targetDEFAULT_UNIVERSE_DOMAIN.downscoped.Credentials(packages/google-auth/google/auth/downscoped.py):credentials.CredentialsWithUniverseDomainand implementwith_universe_domain()(propagating tosource_credentialswhen it exposes a callablewith_universe_domainmethod).universe_domaintoNonein__init__sosource_credentials.universe_domainis inherited by default, validating againstsource_credentials.universe_domainvia_helpers.compare_universe_domains()when explicitly supplied.universe_domain=self._universe_domaininwith_quota_project().compute_engine.Credentials(packages/google-auth/google/auth/compute_engine/credentials.py):universe_domaininwith_universe_domain()via_helpers.validate_universe_domain().universe_domainstate cleanly in_copy_with()and avoid carrying cached default-universe_rab_managerstate onto credentials targeting a non-default universe domain.(Note:
service_accountRAB state handling onwith_universe_domain()is handled separately in #19194.)