Repository navigation
Conversation
Add `universe_domain` support and implement `CredentialsWithUniverseDomain` (`with_universe_domain()`) on `google.auth.jwt.Credentials`, `google.auth.jwt.OnDemandCredentials`, and their `google.auth._jwt_async` subclasses, matching the other credential types in `google-auth`. `universe_domain` is read from service account key info/files and signing credentials (defaulting to `googleapis.com` when omitted, such as in direct constructor calls) and preserved across credential cloning methods, while keeping Regional Access Boundary state scoped to the default universe domain.
There was a problem hiding this comment.
Code Review
This pull request introduces support for universe_domain to both Credentials and OnDemandCredentials classes in google/auth/jwt.py, aligning them with the CredentialsWithUniverseDomain interface. This includes adding the universe_domain parameter to constructors, factory methods, and cloning methods, along with comprehensive unit and async tests to verify behavior such as regional access boundary lookups and impersonation. The review feedback highlights a consistent issue across several cloning methods (with_claims and with_quota_project for both standard and on-demand credentials) where the token_lifetime parameter is not preserved during cloning, causing it to revert to the default value. Implementing the suggested changes to preserve self._token_lifetime will ensure consistency and correctness.
| audience=audience if audience is not None else self._audience, | ||
| additional_claims=new_additional_claims, | ||
| quota_project_id=self._quota_project_id, | ||
| universe_domain=self._universe_domain, | ||
| ) |
There was a problem hiding this comment.
When cloning credentials using with_claims, the token_lifetime parameter is currently not preserved, causing it to revert to the default value. Since with_universe_domain correctly preserves self._token_lifetime, we should also preserve it here for consistency and correctness.
| audience=audience if audience is not None else self._audience, | |
| additional_claims=new_additional_claims, | |
| quota_project_id=self._quota_project_id, | |
| universe_domain=self._universe_domain, | |
| ) | |
| audience=audience if audience is not None else self._audience, | |
| additional_claims=new_additional_claims, | |
| token_lifetime=self._token_lifetime, | |
| quota_project_id=self._quota_project_id, | |
| universe_domain=self._universe_domain, | |
| ) |
| audience=self._audience, | ||
| additional_claims=self._additional_claims, | ||
| quota_project_id=quota_project_id, | ||
| universe_domain=self._universe_domain, | ||
| ) |
There was a problem hiding this comment.
When cloning credentials using with_quota_project, the token_lifetime parameter is currently not preserved, causing it to revert to the default value. We should preserve self._token_lifetime here as well.
| audience=self._audience, | |
| additional_claims=self._additional_claims, | |
| quota_project_id=quota_project_id, | |
| universe_domain=self._universe_domain, | |
| ) | |
| audience=self._audience, | |
| additional_claims=self._additional_claims, | |
| token_lifetime=self._token_lifetime, | |
| quota_project_id=quota_project_id, | |
| universe_domain=self._universe_domain, | |
| ) |
| additional_claims=new_additional_claims, | ||
| max_cache_size=self._cache.maxsize, | ||
| quota_project_id=self._quota_project_id, | ||
| universe_domain=self._universe_domain, | ||
| ) |
There was a problem hiding this comment.
When cloning on-demand credentials using with_claims, the token_lifetime parameter is currently not preserved, causing it to revert to the default value. We should preserve self._token_lifetime here as well.
| additional_claims=new_additional_claims, | |
| max_cache_size=self._cache.maxsize, | |
| quota_project_id=self._quota_project_id, | |
| universe_domain=self._universe_domain, | |
| ) | |
| additional_claims=new_additional_claims, | |
| token_lifetime=self._token_lifetime, | |
| max_cache_size=self._cache.maxsize, | |
| quota_project_id=self._quota_project_id, | |
| universe_domain=self._universe_domain, | |
| ) |
| additional_claims=self._additional_claims, | ||
| max_cache_size=self._cache.maxsize, | ||
| quota_project_id=quota_project_id, | ||
| universe_domain=self._universe_domain, | ||
| ) |
There was a problem hiding this comment.
When cloning on-demand credentials using with_quota_project, the token_lifetime parameter is currently not preserved, causing it to revert to the default value. We should preserve self._token_lifetime here as well.
| additional_claims=self._additional_claims, | |
| max_cache_size=self._cache.maxsize, | |
| quota_project_id=quota_project_id, | |
| universe_domain=self._universe_domain, | |
| ) | |
| additional_claims=self._additional_claims, | |
| token_lifetime=self._token_lifetime, | |
| max_cache_size=self._cache.maxsize, | |
| quota_project_id=quota_project_id, | |
| universe_domain=self._universe_domain, | |
| ) |
Add
universe_domainsupport and implementCredentialsWithUniverseDomain(with_universe_domain()) ongoogle.auth.jwt.Credentials,google.auth.jwt.OnDemandCredentials, and theirgoogle.auth._jwt_asyncsubclasses, matching the other credential types ingoogle-auth.universe_domainis read from service account key info/files and signing credentials (defaulting togoogleapis.comwhen omitted, such as in direct constructor calls) and preserved across credential cloning methods, while keeping Regional Access Boundary state scoped to the default universe domain.