Skip to content

[DRAFT] feat(google-cloud-core): add universe_domain resolution, HTTP validation, and mTLS guards - #19231

Draft
daniel-sanche wants to merge 5 commits into
mainfrom
python_bug_burndown_track_five_google-cloud-core_01_universe-domain
Draft

daniel-sanche wants to merge 5 commits into
mainfrom
python_bug_burndown_track_five_google-cloud-core_01_universe-domain

Conversation

@daniel-sanche

@daniel-sanche daniel-sanche commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Adds universe_domain support and mTLS endpoint guards to google-cloud-core so handwritten clients work consistently outside googleapis.com:

  • Client: Resolves universe_domain from client_options or GOOGLE_CLOUD_UNIVERSE_DOMAIN, validates credentials against the resolved universe when initializing the HTTP session, and passes default_host to AuthorizedSession for self-signed JWTs.
  • JSONConnection: Expands DEFAULT_API_ENDPOINT_TEMPLATE using the client's universe_domain when no custom api_endpoint is set, and restricts mTLS endpoint switching to googleapis.com.
  • make_secure_channel: Forwards default_host to secure_authorized_channel when supported by google-auth.

Note: this design means upstream libraries will have to bump their google-cloud-core floor to make use of the new functionality. I think this is a good trade-off, to avoid duplicating logic in the higher layers. Unlike other dependencies (google-auth, grpc, etc), updating google-cloud-core should have a lower diamond-dependency risk

@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 introduces support for custom universe domains across the Google Cloud Core library. It updates connection and client initialization to resolve the universe domain, validate credentials against the resolved universe, and dynamically format API endpoints. Additionally, it propagates the default service host to AuthorizedSession and secure_authorized_channel when supported. Feedback on these changes highlights two important compatibility issues: first, mock credentials in downstream tests may trigger false-positive UniverseMismatchErrors if their universe_domain attribute returns a mock object; second, older versions of google-auth (prior to 2.23.0) do not support the default_host parameter in AuthorizedSession, which could lead to a TypeError unless handled gracefully.

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