Replace Firebase email/password auth with Admin SDK + GCP Workload Identity#265
Open
jcortejoso wants to merge 1 commit into
Open
Replace Firebase email/password auth with Admin SDK + GCP Workload Identity#265jcortejoso wants to merge 1 commit into
jcortejoso wants to merge 1 commit into
Conversation
Replace email/password authentication (FIREBASE_LOGIN_USERNAME/PASSWORD) with Firebase Admin SDK using GCP Workload Identity Federation for keyless auth from Vercel deployments. On Vercel: exchanges the auto-injected OIDC token for a GCP access token via Workload Identity Federation + service account impersonation. Locally: falls back to Application Default Credentials (gcloud CLI). New env vars required on Vercel: - GCP_WIF_PROVIDER: full WIF provider resource name - GCP_SERVICE_ACCOUNT: SA email to impersonate Env vars no longer needed: - FIREBASE_LOGIN_USERNAME - FIREBASE_LOGIN_PASSWORD
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FIREBASE_LOGIN_USERNAME/FIREBASE_LOGIN_PASSWORD) from Vercelgcloud auth application-default login)What changed
apps/web/utils/gcp-credential.tsCredentialimplementation: Vercel OIDC → GCP WIF → SA impersonationapps/web/utils/firebase.serverside.tsfirebase/compatclient SDK + email/password auth withfirebase-admin/app+firebase-admin/databaseapps/web/package.jsonfirebase-admin, remove@firebase/app-typesGCP setup required (one-time)
Before deploying, create the Workload Identity Pool + Provider in GCP:
Vercel env vars
Add:
GCP_WIF_PROVIDER//iam.googleapis.com/projects/1094498259535/locations/global/workloadIdentityPools/vercel-faucet/providers/vercel-oidcGCP_SERVICE_ACCOUNTfaucet-vercel@celo-faucet.iam.gserviceaccount.comRemove (after deployment verified):
FIREBASE_LOGIN_USERNAMEFIREBASE_LOGIN_PASSWORDTest plan
GCP_WIF_PROVIDERandGCP_SERVICE_ACCOUNTenv vars in Vercel/api/faucetcan write to Firebase RTDBFIREBASE_LOGIN_USERNAME/FIREBASE_LOGIN_PASSWORDfrom Vercel