Repository navigation
fix(auth): four review follow-ups to the SSO/AuthCoordinator PR - #33628
Conversation
The two ETag caches under `IndexResource` were plain `ConcurrentHashMap` instances with no eviction. In practice one basePath serves the whole deployment, so growth was expected to stay tiny — but the repo-wide CLAUDE.md rule "every cache carries a bound" applies regardless, and a proxy reflecting an attacker-controlled path prefix into the key would otherwise grow the map unbounded. Move both to a small Caffeine cache (`maximumSize(32)`); the eviction policy Caffeine chooses (window-TinyLFU) is fine here because entries are content-hashed and the cache is a pure optimisation — a miss just recomputes the SHA-1. Greptile P2: r4052144018. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…er succeeds The earlier strict-write fix propagated storage failures from the CrossTabLock `publish` hook so followers stopped trusting a broadcast that didn't survive reload — but it also signed the current tab out on any transient SW/IndexedDB read hiccup, even though the renewer had just produced a perfectly valid token that never left this process. Two-part fix: 1. `setOidcTokenStrict` now seeds `inMemoryState` with the fresh token before throwing on either the SW-write-failure or SW-already-broken path. `getOidcToken` reads the in-memory fallback in both cases, so the tab's own reads still return the renewed token for the rest of the session; the throw only tells callers that the write is NOT durable across reload. 2. `AuthCoordinator.runExclusiveRefresh` captures the renewer's result before the publish step. If the publish step throws AFTER the renewer succeeded, the leader calls `applyRefreshed(result)` with the in-hand token instead of emitting `refresh-failed`. Followers still get the `failed` broadcast via CrossTabLock's own try/catch and retry through the lock. A renewer failure (real IdP error) still surfaces as `refresh-failed` unchanged. Adds tests pinning both behaviours and reworks the previous "publish-hook failure emits refresh-failed" test to assert the new "tab stays logged in" contract. Greptile P1: r4039793087. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…dc store
The `/silent-callback.html` iframe was constructing `new UserManager({})`,
which falls back to oidc-client's `WebStorageStateStore` → `localStorage`.
The parent tab's `UserManager` is configured with `oidcTokenStorage` as
both `userStore` and `stateStore` (see `getUserManagerConfig` in
`AuthProvider.util.ts`), and `oidcTokenStorage` delegates to
`swTokenStorage` (SW/IndexedDB) whenever the service worker is
available.
Result: in production the parent's `signinSilent()` wrote its saved
state under an SW/IndexedDB key that the iframe's default UserManager
never looked at — `signinSilentCallback()` couldn't find it, the
iframe posted nothing back, and the parent's promise timed out. Wire
the same stores in the iframe so the callback resolves.
Copilot review: r3901422570.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit: python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit # or a separate commit |
✅ Playwright Results — workflow succeededValidated commit ✅ 4541 passed · ❌ 0 failed · 🟡 4 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 52m 36s ⏱️ Max setup 4m 40s · max shard execution 19m 39s · max shard-job elapsed before upload 23m 24s · reporting 15s 🌐 226.14 requests/attempt · 2.23 app boots/UI scenario · 37.15% common-shard skew Optimization targets still in progress:
🟡 4 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
The silent-callback iframe fix on this PR shares `oidcTokenStorage` between `silentCallbackEntry.ts` and the main app graph. Rolldown splits the shared module (plus `swTokenStorage` and `SwTokenStorageUtils`) into a chunk that both HTML entries reference via `<link modulepreload>`, so `MAX_HTML_BOOTSTRAP_JS_FILES` goes from 8 to 9. Byte-neutral — only the count increased. Also apply the prettier reformat CI wanted on the updated `CrossTabLock.test.ts` mock. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ath paths Two bot findings, both real, both narrow-scope: 1. **Handoff-grace on the follower's leader-death race** (greptile r4053143978 / gitar-bot r4053151880). A healthy leader finishes its refresh by calling `notifyDone()` inside `publish` and returning from the lock callback — but BroadcastChannel dispatches asynchronously, so the `done` message can arrive at followers AFTER the lock release grant does. Our follower's blocking `navigator.locks.request` would then win the race, synthesise `failed`, and the coordinator would duplicate-invoke the renewer — which with rotating refresh tokens invalidates the first result. Hold the newly-acquired lock briefly (250 ms) so a pending `done`/`failed` broadcast can land at our listener and win the race via `finish()`. In the truly-crashed-leader case the grace only adds a fixed 250 ms — still orders of magnitude faster than the old 10 s poll and well under any user-perceptible bound. Adds a regression test asserting the follower resolves with the leader's `done` payload when the release/broadcast are ordered as they are in the healthy-finish case. 2. **`setOidcTokenStrict` localStorage path lost the token on throw** (greptile r4053121387). The no-service-worker branch called `localStorage.setItem` directly. On a quota / security-mode throw the coordinator's "renewer succeeded, publish threw → apply locally" branch would return the fresh token, but every subsequent `getOidcToken` read went right back through the same throwing localStorage and missed it — leaving the tab authenticated in memory only for the duration of the current request cycle and forcing repeated re-renews (or a bounce to sign-in). Stage the token in `inMemoryState` AND flip `swStorageBroken` before re-throwing, so `getAppState` routes subsequent reads through the in-memory fallback that the SW-broken path already relies on. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code Review ✅ Approved 1 closed / 1 findings🔴 High risk · Authentication token persistence and cross-tab refresh alter session security behavior. Addresses four SSO/AuthCoordinator follow-ups: bounds unbounded ETag caches with Caffeine, wires the silent-callback iframe to the shared OIDC store, seeds in-memory token state before throwing on strict persistence so the current tab stays authenticated, and extends ✅ 1 closed✅ Bug: Leader-release signal can preempt a valid
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
|
|
🚦 Removed from the merge queue —
|
🚦 Removed from the merge queue —
|



Summary
Three review follow-ups from PR #31675 (SSO / AuthCoordinator refactor). Each is small and independent; kept as separate commits so they can be reviewed one at a time.
ConcurrentHashMapinstances with no eviction. Moved to Caffeine withmaximumSize(32); entries are content-hashed and a miss just recomputes the SHA-1, so eviction is safe.setOidcTokenStrictseedsinMemoryStatebefore throwing (sogetOidcTokenstill returns the fresh token), andAuthCoordinator.runExclusiveRefreshapplies the refresh locally when persist throws after renewer succeeds (only real renewer failures still emitrefresh-failed).new UserManager({})in the iframe defaulted toWebStorageStateStore(localStorage); the parent usesoidcTokenStoragewhich delegates to SW/IndexedDB in production. Different stores → iframe'ssigninSilentCallback()couldn't find the saved state → parent'ssigninSilent()timed out. Iframe now uses the same store.Explicitly NOT included: greptile P1 r4043885089 ("Slow leader still logs out"). This is a real edge case — a leader IdP round-trip >20s exhausts both
MAX_RECOVERY_ATTEMPTS=1follower-wait windows and the follower signs out even if the leader eventually succeeds. Fixing it needs a design decision (extend the retry ladder vs add a leader-heartbeat broadcast) that's better handled in its own PR.Test plan
yarn jest src/utils/SwTokenStorageUtils.test.ts src/utils/Auth/AuthCoordinator/__tests__/AuthCoordinator.test.ts— 67/67 passyarn eslint --no-warn-ignoredon all touched TS/TSX files — clean🤖 Generated with Claude Code
Summary by Gitar
CrossTabLocksoft ceiling to60sand added Web Lock release detection for near-instant follower failure recoveryThis will update automatically on new commits.
The PR appears safe to merge; both previous findings are no longer outstanding and no actionable new regression was established.
Findings
Summary
This PR addresses authentication and resource-cache review follow-ups:
Diagram
sequenceDiagram participant F as Follower tab participant L as Web Lock participant A as Leader tab participant S as Token storage participant B as BroadcastChannel A->>L: Acquire refresh lock F->>B: Attach terminal-message listener F->>L: Probe lock, then wait for release A->>A: Renew token A->>S: Persist token strictly alt persistence succeeds A->>B: Broadcast done(token) A-->>L: Release lock B-->>F: Apply refreshed token else persistence fails after renewal A->>A: Keep token in memory A->>B: Broadcast failed A-->>L: Release lock A->>A: Apply refresh locally B-->>F: Retry through shared lock endReviews (4) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."