Skip to content

Remove Impersonated wrap, rely on ADC for auth#4

Open
robin-morton wants to merge 3 commits into
fix-auth-firebasefrom
fix-auth-adc-direct
Open

Remove Impersonated wrap, rely on ADC for auth#4
robin-morton wants to merge 3 commits into
fix-auth-firebasefrom
fix-auth-adc-direct

Conversation

@robin-morton

Copy link
Copy Markdown
Collaborator

Summary

  • Removes the explicit Impersonated wrap and the hardcoded main-service-account@<projectId>.iam.gserviceaccount.com target from src/index.js.
  • Lets Firestore, SecretManagerServiceClient, and admin.initializeApp pick up Application Default Credentials directly.
  • Collapses the emulator and non-emulator branches since both now use the same client construction.

Why

Per #3, the hardcoded impersonation target breaks local auth in two ways:

  1. AS8-specific SA namemain-service-account@${projectId}… doesn't generalize; consumers in other projects can't use this fork.
  2. Double-impersonation — when an engineer runs 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

  • CI — confirm migrations still run under the OIDC external_account credentials file
  • Local with plain ADC (gcloud auth application-default login) — confirm auth via tokenCreator works
  • Local with impersonating ADC (gcloud auth application-default login --impersonate-service-account=…) — previously failed with INVALID_ARGUMENT; should now succeed
  • Emulator path (FIRESTORE_EMULATOR_HOST=…) — unchanged behavior, existing test suite passes

Notes

  • This PR targets fix-auth-firebase because the consuming project pins https://github.com/akeneo/fireway#fix-auth-firebase. master can be updated separately if needed.
  • google-auth-library is no longer imported directly but remains a transitive dep; left in package.json to keep this change focused on the wrapper removal.

Closes #3

🤖 Generated with Claude Code

robin-morton and others added 3 commits May 8, 2026 16:41
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant