GoogleCloudPlatform / GoogleCloudPlatform/cloud-sql-proxy
[BUG] universe-domain is not propagated to IAMCredentials client when using impersonate-service-account
- Lingua principale
- Go
- Stelle
- 1.4k
- Fork
- 352
- Merge medio
- 14h 54m
- PR unite (30g)
- 5
Descrizione
### Bug Description
When running cloud-sql-proxy in a custom universe domain (e.g., s3nsapis.fr) with service account impersonation enabled (impersonate-service-account), the proxy fails during startup when attempting to refresh instance metadata, returning HTTP 401 ACCESS_TOKEN_TYPE_UNSUPPORTED.
An analysis of the error payload indicates that while the proxy correctly targets the custom universe domain for the Cloud SQL Admin API (sqladmin.s3nsapis.fr), the underlying client created for Service Account impersonation still defaults to the public Google IAM endpoint (iamcredentials.googleapis.com).
### Environment
- Cloud SQL Proxy Version: v2.24.1
- OS: macOS / Linux
- Authentication Method: Custom Universe Domain Credentials / Workforce Identity Federation (WIF)
### Configuration Used
```toml
instance-connection-name = "s3ns:sandbox-yohan-xxxx:u-france-east1:mydatabase"
universe-domain = "s3nsapis.fr"
impersonate-service-account = "my-app@sandbox-yohan-xxxx.s3ns.iam.gserviceaccount.com"
psc = true
```
### Steps to Reproduce
1- Log in with a principal in a custom universe domain (e.g., s3nsapis.fr).
2- Run cloud-sql-proxy configured with both universe-domain and impersonate-service-account.
3- Observe the proxy initialization log.
### Observed Behavior
The proxy fails to fetch instance metadata with the following error log:
```
2026/07/28 14:27:43 Impersonating service account with gcloud user credentials
2026/07/28 14:27:44 [s3ns:sandbox-yohan-09e8:u-france-east1:demo-replatforming] could not resolve instance version: failed to get instance: refresh error: failed to get instance metadata (connection name = "s3ns:sandbox-yohan-09e8:u-france-east1:demo-replatforming"): Get "https://sqladmin.s3nsapis.fr/sql/v1beta4/projects/s3ns%3Asandbox-yohan-09e8/instances/demo-replatforming/connectSettings?alt=json&prettyPrint=false": impersonate: status code 401: {
"error": {
"code": 401,
"message": "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.",
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "ACCESS_TOKEN_TYPE_UNSUPPORTED",
"metadata": {
"method": "google.iam.credentials.v1.IAMCredentials.GenerateAccessToken",
"service": "iamcredentials.googleapis.com"
}
}
]
}
}
```
Notice in the error metadata:
"service": "iamcredentials.googleapis.com" (Points to public Google Cloud instead of iamcredentials.s3nsapis.fr).
### Expected Behavior
The universe-domain option should be propagated to the IAM Credentials client used by google.golang.org/api/impersonate during token generation. The proxy should call https://iamcredentials./... (e.g., iamcredentials.s3nsapis.fr) instead of iamcredentials.googleapis.com.
### Root Cause Analysis
When universe-domain is configured, it is successfully applied to the Cloud SQL Admin API client (sqladmin.). However, when initializing the credentials for impersonate-service-account, the universe-domain configuration is not passed down to the impersonate package options (option.WithUniverseDomain(...)). Consequently, the impersonate client defaults to googleapis.com, which rejects authentication tokens issued by custom universe domains.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia tracciando come il universe-domain configurato raggiunge il client google.golang.org/api/impersonate e confronta questo percorso con quello del client Cloud SQL Admin. Controlla le opzioni di impersonate relative a option.WithUniverseDomain(...), quindi verifica l’avvio con universe-domain e impersonate-service-account configurati e conferma che le richieste siano indirizzate a iamcredentials..
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- go, google-cloud
- Ambito
- authentication, cloud
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 68/100