Remove Impersonated wrap, rely on ADC for auth#4
Open
robin-morton wants to merge 3 commits into
Open
Conversation
The hardcoded main-service-account impersonation in src/index.js breaks local auth: when ADC is already impersonating that SA (via gcloud auth application-default login --impersonate-service-account=…), the chain becomes "main-SA impersonating main-SA" and IAM rejects it with INVALID_ARGUMENT. It also pins the SA name to AS8's convention, making this fork unusable elsewhere. Drop the explicit Impersonated wrap and the hardcoded SA. Both CI (external_account creds via OIDC) and engineers locally (impersonating ADC) already produce credentials that mint the right token; fireway doesn't need to add another layer. The Firestore, SecretManager, and firebase-admin clients pick up ADC on their own. Closes #3 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
google-auth-library is no longer imported now that the Impersonated wrap is gone. firebase-admin still pulls it transitively. Bumps within existing ranges: - @elastic/elasticsearch 9.2.1 → 9.4.0 - @google-cloud/firestore 8.3.0 → 8.5.0 - @google-cloud/secret-manager 6.1.1 → 6.1.2 - firebase-admin 13.7.0 → 13.9.0 - semver 7.3.7 → 7.7.4 callsites is held at v3 — v4 is ESM-only and fireway uses CommonJS. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous behaviour (drop Impersonated wrap, use ADC directly) works when ADC is already configured to mint tokens for the target identity — e.g. a local user running `gcloud auth application-default login --impersonate-service-account=...`. But it doesn't work in CI flows where ADC produces a federated/ci identity and the consumer needs a different SA's permissions. Reintroduce the Impersonated wrap, but only when FIREWAY_IMPERSONATE_SA is set, and use that env var's value as the target. Callers control: - Local: `gcloud ... --impersonate-service-account=main-SA` → no env var → fireway uses ADC directly → main-SA tokens. - CI: env var `FIREWAY_IMPERSONATE_SA=main-SA` → fireway wraps the federated/ci ADC client with Impersonated → main-SA tokens via one-hop impersonation. No hardcoded service-account names. Re-adds google-auth-library as a direct dep (it was dropped in the previous commit).
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
Impersonatedwrap and the hardcodedmain-service-account@<projectId>.iam.gserviceaccount.comtarget fromsrc/index.js.Firestore,SecretManagerServiceClient, andadmin.initializeApppick up Application Default Credentials directly.Why
Per #3, the hardcoded impersonation target breaks local auth in two ways:
main-service-account@${projectId}…doesn't generalize; consumers in other projects can't use this fork.gcloud auth application-default login --impersonate-service-account=main-service-account@…, ADC is already minting main-SA tokens. The wrap then asks IAM Credentials to "impersonate main-SA using main-SA token" →INVALID_ARGUMENT: unable to impersonate.Both CI (external_account creds via OIDC) and engineers locally (impersonating ADC) already produce credentials that mint the right token. Fireway doesn't need to add another layer; ADC is the single source of truth.
Test plan
external_accountcredentials filegcloud auth application-default login) — confirm auth via tokenCreator worksgcloud auth application-default login --impersonate-service-account=…) — previously failed withINVALID_ARGUMENT; should now succeedFIRESTORE_EMULATOR_HOST=…) — unchanged behavior, existing test suite passesNotes
fix-auth-firebasebecause the consuming project pinshttps://github.com/akeneo/fireway#fix-auth-firebase.mastercan be updated separately if needed.google-auth-libraryis no longer imported directly but remains a transitive dep; left inpackage.jsonto keep this change focused on the wrapper removal.Closes #3
🤖 Generated with Claude Code