Repository navigation
[DRAFT] feat(google-cloud-core): add universe_domain resolution, HTTP validation, and mTLS guards - #19231
[DRAFT] feat(google-cloud-core): add universe_domain resolution, HTTP validation, and mTLS guards#19231daniel-sanche wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
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.
Adds
universe_domainsupport and mTLS endpoint guards togoogle-cloud-coreso handwritten clients work consistently outsidegoogleapis.com:Client: Resolvesuniverse_domainfromclient_optionsorGOOGLE_CLOUD_UNIVERSE_DOMAIN, validates credentials against the resolved universe when initializing the HTTP session, and passesdefault_hosttoAuthorizedSessionfor self-signed JWTs.JSONConnection: ExpandsDEFAULT_API_ENDPOINT_TEMPLATEusing the client'suniverse_domainwhen no customapi_endpointis set, and restricts mTLS endpoint switching togoogleapis.com.make_secure_channel: Forwardsdefault_hosttosecure_authorized_channelwhen supported bygoogle-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