agent/gcp: derive service account from credentials instead of hardcoding 'default' - #32080
agent/gcp: derive service account from credentials instead of hardcoding 'default'#32080Damini008 wants to merge 3 commits into
Conversation
…ing 'default' When type=iam and no service_account is explicitly set, the agent was sending the literal string 'default' to the GCP IAM SignJwt API, which returns Error 400: Invalid form of account ID. Fix: leave serviceAccount empty at construction. In the IAM branch, fall back to credentials.ClientEmail from GOOGLE_APPLICATION_CREDENTIALS before returning an error. GCE branch continues to use 'default' as a valid metadata-server alias. Fixes: hashicorp/vault-plugin-auth-gcp#183
|
Deployment failed for project vault-ui with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Damini008 seems not to be a GitHub user. Have you signed the CLA already but the status is still pending? Recheck it. |
|
Deployment failed for project vault-ui with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
|
Deployment failed for project vault-ui with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
4153dbd to
15545ed
Compare
|
Deployment failed for project vault-ui with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
Problem
When
type=iamand noservice_accountis explicitly set in theauto_auth config, the Vault agent was sending the literal string
"default"to the GCP IAMSignJwtAPI, which rejects it with:This happened because
serviceAccountwas hardcoded to"default"atconstruction time, which prevented the fallback to
credentials.ClientEmail(populated fromGOOGLE_APPLICATION_CREDENTIALS)from ever being reached.
Fix
"default"from the constructorAuthenticate, fall back tocredentials.ClientEmailwhen no explicitservice_accountis configured"default"locally as a metadata-serveralias — this is valid for GCE and behaviour is unchanged
Testing
Added unit tests covering:
service_accountconfigured → field is empty (key regression guard)service_account→ preserved as-isservice_account→ empty at constructiontype, missingrole, nil config → all return errorsRelated
Fixes: hashicorp/vault-plugin-auth-gcp#183