feat: support universe domain in service account and metadata credentials#482
feat: support universe domain in service account and metadata credentials#482
Conversation
|
|
||
| $this->projectId = $jsonKey['project_id'] ?? null; | ||
| $this->universeDomain = $jsonKey['universe_domain'] ?? null; | ||
| $this->universeDomain = $jsonKey['universe_domain'] ?? self::DEFAULT_UNIVERSE_DOMAIN; |
There was a problem hiding this comment.
Should we also throw in case there's domain-delegation?
I am not very sure but it appears that we need to throw (near line#146) in case sub as well as universe_domain is set in the key, as per AL9 of the universe domain spec
There was a problem hiding this comment.
Thank you for catching this, I completely missed it. PHP definitely supports domain-delegation
google-auth-library-php/src/Credentials/ServiceAccountCredentials.php
Lines 114 to 115 in b687d5e
I'll look more into it
vishwarajanand
left a comment
There was a problem hiding this comment.
Lgtm, approving since there are no major comments.
Tests:
-
I tested the changes on
apis-tpclp.googuniverse domain and validated thatServiceAccountCredentialsgenerates a valid access_token while using the provided universe domain value. -
I was also able to query the compute instances in the project on the URL:
https://compute.apis-tpclp.goog/compute/staging_v1/<more params>, which captures the universe domain in the endpoint. -
When I use the access token generated in step#1, and use the regular compute api:
https://compute.googleapis.com/compute/staging_v1/<more params>I see an expected failure with error code 401 and statusUNAUTHENTICATED:
Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Requirements
Authentication libraries must add the universe_domain property to the token authentication credentials constructor (if supported) and document the default behaviorNot applicable unless we add an Access Token credential typegoogleapis.comgoogleapis.comIdTokenflow for Service Accounts when authenticating outsidegoogleapis.comor throw an exceptionDependencies