Skip to content

Commit 196839f

Browse files
authored
Skip openidconnect call for user email if universe_domain detected (#15009)
1 parent 8e982f5 commit 196839f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

mmv1/third_party/terraform/transport/config.go.tmpl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,12 @@ func ConfigureBasePaths(c *Config) {
15201520
}
15211521

15221522
func GetCurrentUserEmail(config *Config, userAgent string) (string, error) {
1523+
ud := config.UniverseDomain
1524+
if ud != "" && ud != "googleapis.com" {
1525+
log.Printf("[INFO] Configured universe domain detected. Skipping user email retrieval.")
1526+
return "", nil
1527+
}
1528+
15231529
// When environment variables UserProjectOverride and BillingProject are set for the provider,
15241530
// the header X-Goog-User-Project is set for the API requests.
15251531
// But it causes an error when calling GetCurrentUserEmail. Set the project to be "NO_BILLING_PROJECT_OVERRIDE".
@@ -1528,9 +1534,10 @@ func GetCurrentUserEmail(config *Config, userAgent string) (string, error) {
15281534
// See https://github.com/golang/oauth2/issues/306 for a recommendation to do this from a Go maintainer
15291535
// URL retrieved from https://accounts.google.com/.well-known/openid-configuration
15301536
res, err := SendRequest(SendRequestOptions{
1531-
Config: config,
1532-
Method: "GET",
1537+
Config: config,
1538+
Method: "GET",
15331539
Project: "NO_BILLING_PROJECT_OVERRIDE",
1540+
// URL does not need to be universe domain-aware since we return early for non-GDU universes
15341541
RawURL: "https://openidconnect.googleapis.com/v1/userinfo",
15351542
UserAgent: userAgent,
15361543
})

0 commit comments

Comments
 (0)