Skip to content

fix(auth): four review follow-ups to the SSO/AuthCoordinator PR - #33628

Merged
chirag-madlani merged 10 commits into
mainfrom
sso-auth-followups
Sep 22, 2026
Merged

chirag-madlani merged 10 commits into
mainfrom
sso-auth-followups

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Sep 19, 2026 •

Copy link
Copy Markdown
Collaborator

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.

  • fix(service): bound the index / silent-callback ETag caches — greptile P2 r4052144018. Both ETag caches were plain ConcurrentHashMap instances with no eviction. Moved to Caffeine with maximumSize(32); entries are content-hashed and a miss just recomputes the SHA-1, so eviction is safe.
  • fix(ui): keep tab authenticated when strict persist fails after renewer succeeds — greptile P1 r4039793087. The previous strict-write fix propagated storage failures so followers stopped trusting an un-durable broadcast — but it also signed the current tab out on any transient SW/IndexedDB hiccup, even when the renewer had produced a valid token. Two-part fix: setOidcTokenStrict seeds inMemoryState before throwing (so getOidcToken still returns the fresh token), and AuthCoordinator.runExclusiveRefresh applies the refresh locally when persist throws after renewer succeeds (only real renewer failures still emit refresh-failed).
  • fix(ui): wire the silent-callback iframe UserManager to the shared oidc store — copilot r3901422570. new UserManager({}) in the iframe defaulted to WebStorageStateStore (localStorage); the parent uses oidcTokenStorage which delegates to SW/IndexedDB in production. Different stores → iframe's signinSilentCallback() couldn't find the saved state → parent's signinSilent() 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=1 follower-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 pass
  • yarn eslint --no-warn-ignored on all touched TS/TSX files — clean
  • Java unit tests (IndexResourceTest) — verified via CI
  • Playwright silent-refresh scenarios pick up the iframe store wiring — verified via CI

🤖 Generated with Claude Code


Summary by Gitar

  • Authentication & Cross-Tab Locking:
    • Extended CrossTabLock soft ceiling to 60s and added Web Lock release detection for near-instant follower failure recovery
    • Prevented late-arriving broadcast loss by attaching message listeners before checking lock availability

This will update automatically on new commits.

RetriggerConfidence Score: 5/5

The PR appears safe to merge; both previous findings are no longer outstanding and no actionable new regression was established.

Findings

  1. P1 Refresh Uses Unstored Token ▶
Summary

This PR addresses authentication and resource-cache review follow-ups:

  • Bounds both server-side ETag caches with Caffeine.
  • Shares the parent OIDC state store with the silent-callback iframe.
  • Preserves a successfully renewed token in the current tab when durable storage fails.
  • Improves cross-tab refresh coordination with earlier listener registration, lock-release detection, a longer soft timeout, and a handoff grace.
  • Adds focused regression coverage for persistence failures and cross-tab lock handoff behavior.
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
  end
Loading

Reviews (4) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

chirag-madlani and others added 3 commits September 19, 2026 17:26
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>
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Sep 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 796 → 797
- 1 added, 0 removed, 13 changed spec-list

New source→spec entries:
  openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedEditor/ActivityFeedEditorNew.tsx

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/playwright/utils/taskWorkflow.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/waitHelpers.ts
  openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCardNew/ActivityFeedcardNew.component.tsx
  openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCardNew/CommentCard.component.tsx
  openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedEditor/SendButton.tsx
  openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/FeedEditor/FeedEditor.tsx
  openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/Shared/ActivityFeedActions.tsx
  openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/TaskFeedCard/TaskFeedCardFromTask.component.tsx
  openmetadata-ui/src/main/resources/ui/src/components/Entity/Task/TaskTab/TaskTabNew.component.tsx
  openmetadata-ui/src/main/resources/ui/src/components/common/RichTextEditor/RichTextEditorPreviewNew.tsx
  … and 3 more

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 getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

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

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 7d025a60d4ce54ddefcbd77065482e250e393743 in Playwright run 35563049694, attempt 1.

✅ 4541 passed · ❌ 0 failed · 🟡 4 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky

Performance

Blocking 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:

  • Common shard skew was 37.15% (convergence target: at most 15%).
  • Browser traffic was 226.14 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.23 per UI scenario (10767 boots / 4827 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard advanced-search-01 58 0 0 0 0 0
✅ Shard advanced-search-02 72 0 0 0 0 0
✅ Shard chromium-01 123 0 0 0 0 0
✅ Shard chromium-02 161 0 0 0 0 0
✅ Shard chromium-03 158 0 0 0 0 0
🟡 Shard chromium-04 138 0 1 0 0 0
✅ Shard chromium-05 178 0 0 0 0 0
✅ Shard chromium-06 162 0 0 0 0 0
✅ Shard chromium-07 129 0 0 0 0 0
✅ Shard chromium-08 151 0 0 0 0 0
✅ Shard chromium-09 161 0 0 0 0 0
✅ Shard chromium-10 153 0 0 0 0 0
✅ Shard chromium-11 177 0 0 0 0 0
✅ Shard chromium-12 139 0 0 0 0 0
✅ Shard chromium-13 169 0 0 0 0 0
✅ Shard chromium-14 172 0 0 0 0 0
🟡 Shard chromium-15 196 0 1 0 0 0
✅ Shard chromium-16 191 0 0 0 0 0
✅ Shard chromium-17 177 0 0 0 0 0
🟡 Shard chromium-18 156 0 1 1 0 0
✅ Shard chromium-19 173 0 0 0 0 0
✅ Shard chromium-20 169 0 0 0 0 0
🟡 Shard chromium-21 181 0 1 0 0 0
✅ Shard chromium-22 132 0 0 0 0 0
✅ Shard chromium-23 147 0 0 0 0 0
✅ Shard chromium-24 137 0 0 0 0 0
✅ Shard chromium-25 136 0 0 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard import-export-01 34 0 0 0 0 0
✅ Shard import-export-02 65 0 0 0 0 0
✅ Shard import-export-03 51 0 0 0 0 0
✅ Shard ingestion-01 51 0 0 0 0 0
✅ Shard ingestion-02 48 0 0 0 0 0
✅ Shard reindex-01 40 0 0 0 0 0
✅ Shard search-01 12 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 4 flaky test(s) (passed on retry)
  • Pages/ServiceEntity.spec.ts › Delete Database Schema (shard chromium-04, 1 retry)
  • Pages/Entity.spec.ts › Tag and Glossary Term preservation in column detail panel (shard chromium-15, 1 retry)
  • Pages/DomainUIInteractions.spec.ts › Remove owner from domain via UI (shard chromium-18, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard chromium-21, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

chirag-madlani and others added 4 commits September 19, 2026 21:13
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>
@gitar-bot

gitar-bot Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
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 CrossTabLock release detection to prevent late-arriving broadcast loss. All findings resolved.

✅ 1 closed
✅ Bug: Leader-release signal can preempt a valid done broadcast

📄 openmetadata-ui/src/main/resources/ui/src/utils/Auth/AuthCoordinator/CrossTabLock.ts:278-292 📄 openmetadata-ui/src/main/resources/ui/src/utils/Auth/AuthCoordinator/CrossTabLock.ts:283-289
raceForFollowerOutcome races the leader's done/failed broadcast against the follower's blocking Web Lock request. In the normal-finish case the leader persists the token, calls notifyDone, then returns from the lock callback (releasing the lock). The done postMessage and the lock release are delivered to the follower through separate, cross-context channels whose relative ordering is not guaranteed. When the lock-release grant is delivered first, finish resolves with the synthetic {type:'failed', reason:'leader released lock without broadcasting'} and calls listener.cancel(), discarding the real done payload that was in flight. The coordinator then treats this as a follower failure and calls runExclusiveRefresh(renewer, attempt+1), which re-acquires the lock and invokes renewer() again with no freshness re-check — a redundant IdP round-trip that defeats the "exactly one /auth/refresh across tabs" goal the coordinator is built around, even on a perfectly healthy leader. The comment lists "finished + released the lock normally" as an intended trigger, but it does not account for it preempting a legitimate done.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-21T13:59:37Z)

Blocked the queue: integration-tests-postgres-opensearch, integration-tests-mysql-elasticsearch

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-21T19:38:14Z)

Blocked the queue: integration-tests-mysql-elasticsearch

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants