Repository navigation
fix(auth): drop a stored API key when Firebase ends the sign-in on Cloud - #23500
Conversation
PR 22541 made a stored API key the login once no Firebase user is left, and logout() removes the key so that signing out leaves no login behind. Firebase can also end a sign-in on its own: it signs out a disabled or expired user from inside the SDK, and that path does not go through logout(). The request in flight got no credential, but the key stayed in storage, so the next request was sent with it. That key can belong to another account. The store now watches currentUser synchronously and removes the stored key on Cloud whenever a Firebase user is replaced by none, whichever path ended the sign-in. A first answer of "nobody is signed in" has no previous user, so an API-key-only tab keeps its key. Off Cloud the key is kept, as before.
📦 Bundle: 12.4 MB gzip 🔴 +29 BDetailsSummary
Category Glance App Entry Points — 7.26 kB (baseline 7.26 kB) • ⚪ 0 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 3.69 MB (baseline 3.69 MB) • ⚪ 0 BGraph editor runtime, canvas, workflow orchestration
Status: 2 added / 2 removed / 3 unchanged Views & Navigation — 152 kB (baseline 152 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 10 added / 10 removed / 8 unchanged Panels & Settings — 899 kB (baseline 899 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
Status: 7 added / 7 removed / 28 unchanged User & Accounts — 107 kB (baseline 107 kB) • 🔴 +68 BAuthentication, profile, and account management bundles
Status: 10 added / 10 removed / 8 unchanged Editors & Dialogs — 509 kB (baseline 509 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 13 added / 13 removed / 6 unchanged UI Components — 374 kB (baseline 374 kB) • ⚪ 0 BReusable component library chunks
Status: 6 added / 6 removed / 28 unchanged Data & Services — 2.01 MB (baseline 2.01 MB) • ⚪ 0 BStores, services, APIs, and repositories
Status: 9 added / 9 removed / 37 unchanged Utilities & Hooks — 1.44 MB (baseline 1.44 MB) • ⚪ 0 BHelpers, composables, and utility bundles
Status: 27 added / 27 removed / 59 unchanged Vendor & Third-Party — 9.7 MB (baseline 9.7 MB) • ⚪ 0 BExternal libraries and shared vendor chunks Status: 16 unchanged Other — 36.6 MB (baseline 36.6 MB) • ⚪ 0 BBundles that do not match a named category
Status: 69 added / 69 removed / 699 unchanged ⚡ Performance: ⏳ Performance tests in progress…🎭 Playwright: ✅ 3329 passed, 0 failed · 1 flaky📊 Browser Reports
🎨 Storybook: ✅ Built — View Storybook🧩 Custom Nodes Ecosystem Matrix: 🟡 Withheld — could not measure
Findings and check detailsExecutes the frontend JS of every registry pack that ships any, against this change, in both renderers. The eight The matrix runs on same-repository version-bump PRs with relevant changes, main-branch pushes, and manual dispatches. This candidate does not qualify, so every expensive stage was skipped. Full docs: scripts/registry-census/README.md Reproduce locally# build one shard's fixture, then run it
python3 scripts/registry-census/build_matrix.py --shard 1/4
MATRIX_RENDERER=vue MATRIX_VUE=1 \
npx vitest run --config vitest.matrix.config.mts
🌾 Fallow: ✅ PassedFindings and check detailsFallow audits the diff for duplication, complexity and dead code. It gates on new findings only, so when the audit completes, a red is something this PR introduced or moved — never inherited backlog. A red can also mean the audit itself did not finish; the details below say which happened. No new findings in the changed files. Full docs: ADR-DEVEX-LINT-0015 Reproduce locally# the base the gate compared against
npx fallow audit --root . --quiet --format json \
--changed-since 1baae5f1cfdc5bbf2502066e1b5f842568effb87
🏛️ Architecture: ✅ PassedFindings and check detailsWarnings (518)
Full docs: Frontend domain catalog Reproduce locallypnpm architecture:check |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #23500 +/- ##
==========================================
- Coverage 88.02% 87.94% -0.08%
==========================================
Files 3173 3061 -112
Lines 169943 166309 -3634
Branches 45873 44648 -1225
==========================================
- Hits 149592 146267 -3325
+ Misses 19379 19239 -140
+ Partials 972 803 -169
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 137 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
Starting review at e338e25. |
|
Approving at e338e25. Clean: Correctness, Resilience, Access, Words, Contract, Vendor, Rollout, Rules, Cause. Not covered: Access/Vendor - real Firebase invalidation with an older stored key, followed by reload (Cloud staging read). Related browser command: Checked: read, not run: the Cloud identity transition at ~1.2M effective tokens for this review (7.0M raw; cache reads weighted 0.1x, cache writes 1.25-2x) |
…e only cloud login (#22541, #23500) (#23494) ```mermaid graph LR A["PR 22541 (merged): send the stored API key when it is the only cloud login"] --> B["this PR: manual backport of both to core/1.60"] F["PR 23500 (merged): drop the stored key when Firebase ends the sign-in on Cloud"] --> B A --> C["PR 23495 (open): the same backport to cloud/1.60"] F --> C style B stroke-width:3px ``` Manual backport to `core/1.60` of #22541 and its follow-up #23500, one commit each. ## Summary **Why.** #22541 fixes a Cloud tab that is signed in only with a stored API key: every API call returned 401 and Run did nothing. It carries `needs-backport` for the 1.60 line. The review of this backport then found that Firebase's own sign-out left an earlier stored key in place as the next login; #23500 fixes that on `main`, and this branch takes it so that the 1.60 line does not ship the first change without the second. **Root cause of the failed cherry-pick.** On `main` the #22541 change sits directly below `getFreshIdToken`, which arrived with #23402 (1.61) and does not exist on `core/1.60`. Git reported that block as a conflict in `src/stores/authStore.ts`. **How.** - Commit 1 (`9e9382f394`, #22541): the `getFreshIdToken` block is left out, so no 1.61 code comes along. The added and removed lines in all seven files are the same as in the merged commit; only the surrounding context in `authStore.ts` differs. - Commit 2 (`103d6a8d02`, #23500): applied without conflict. Its three files carry the same added lines as the merged commit. - `core/1.60` and `cloud/1.60` are identical in every file touched, so both backports carry the same diff. What the two changes do, as on `main`: - With unified auth on, an API-key-only session sends the stored key from `getAuthHeader` and `getWorkspaceAuthHeader`, and only after Firebase has confirmed that nobody is signed in. - Remote widgets send the Cloud credential only to same-origin routes. - On Cloud a stored API key is removed whenever a Firebase sign-in ends: in `logout()` before it signs out, and when Firebase ends the sign-in on its own. ## AS IS / TO BE Same as #22541 and #23500; see the screenshots and the table there. Not captured again on this branch. ## Verification - `pnpm install --frozen-lockfile` on this branch, then `pnpm test:unit src/platform/auth src/stores src/composables/auth src/platform/workspace src/renderer/extensions/vueNodes/widgets/composables/useRemoteWidget.test.ts`: `Test Files 141 passed (141)`, `Tests 3278 passed | 1 expected fail (3279)`. - Each commit's diff was compared with its merged commit: the added and removed lines match. - The commit hook ran oxfmt, oxlint, eslint, `lint:server-facts` and `typecheck:app`. - Not run: the Playwright suites, and nothing against a real Cloud backend with a real API key. ## Not in this backport The socket credential for an API-key-only tab (the Should fix from the review). It is not fixed on `main` either.
…ey test on the unified path Rebasing onto main brought in #22541 and #23500, which send a stored API key when it is the only Cloud login and drop it when Firebase ends a sign-in. The flag-removal commit had deleted the three stored-key boot rows that main still runs; they pass again, and the new #23500 suite no longer sets the removed flag.
…ey test on the unified path Rebasing onto main brought in #22541 and #23500, which send a stored API key when it is the only Cloud login and drop it when Firebase ends a sign-in. The flag-removal commit had deleted the three stored-key boot rows that main still runs; they pass again, and the new #23500 suite no longer sets the removed flag.
Follow-up to #22541, from the review of its
core/1.60backport (#23494 (comment)). The finding applies tomainas well.Summary
Why. A Cloud user is signed in with Firebase as account A, and the browser still holds an API key that was stored earlier for account B. Firebase ends A's sign-in on its own, for example because the account was disabled or its refresh token expired. From the next request on, the tab authenticates as B without anyone signing in.
Root cause. #22541 made a stored API key the login once no Firebase user is left, and it removes the key in
logout()so that signing out leaves no login behind. Firebase's automatic sign-out does not go throughlogout(). It only fires the identity callback (firebaseIdentity.onUserChanged), which setscurrentUsertonulland leaves the key in storage. The request in flight gets no credential, butstoredApiKeyAsOnlyLoginthen sees an initialized store with no Firebase user and answers with the key.mainbefore #22541 answerednullon both header getters in that state.How. The store watches
currentUsersynchronously and, on Cloud, removes the stored key whenever a Firebase user is replaced by none. That covers every path that ends a sign-in, not onlylogout().logout()still removes the key before it signs out, so the window during sign-out stays closed. The watcher then finds no key and does nothing.The user sees the existing "API key cleared" toast when this happens, the same one a Cloud sign-out shows since #22541.
No feature gate: this narrows a credential path that #22541 opened, and waiting behind a flag would leave the path open.
AS IS / TO BE
No UI change, so there is nothing to screenshot. Unified auth on, Cloud, Firebase user A signed in, key B stored:
getAuthHeader)getWorkspaceAuthHeader)Verification
Red, with the new cases and without the fix (
pnpm test:unit src/stores/__tests__/authTokenPriority.test.ts src/stores/authStore.test.ts -t "<the three new titles>"):The two that pass before the fix guard it against removing too much: "keeps the stored API key off Cloud when Firebase ends the sign-in" and "keeps the stored key when the first Firebase answer is that nobody is signed in".
Green, with the fix:
pnpm test:unit src/platform/auth src/stores src/composables/auth src/platform/workspace src/renderer/extensions/vueNodes/widgets/composables/useRemoteWidget.test.tsgivesTest Files 144 passed (144),Tests 3476 passed | 1 expected fail (3477).The commit hook ran oxfmt, oxlint, eslint,
lint:server-factsandtypecheck:app.Not added: a browser spec that invalidates a Firebase user mid-session.
authAccountSwitch.spec.tsruns with unified auth off.Not run: anything against a real Cloud backend, and no real Firebase invalidation.
Not in this PR
The same review has a Should fix: an API-key-only Cloud tab can now queue a run over HTTP, but its WebSocket still carries no credential, so execution events do not arrive. That needs the socket path to carry the key and Cloud to accept it there. It is not changed here.