Skip to content

fix(auth): OIDC login-loop hardening — interactive fallback on login_required, preserve pending logins (2.0) - #31182

Closed
mohityadav766 wants to merge 2 commits into
2.0from
fix/2.0-oidc-login-loop-30304
Closed

mohityadav766 wants to merge 2 commits into
2.0from
fix/2.0-oidc-login-loop-30304

Conversation

@mohityadav766

Copy link
Copy Markdown
Member

Cherry-pick of #31181 onto 2.0 (files are identical between main and 2.0). Part of #30304.

  • handleCallback: login_required/interaction_required/consent_required/account_selection_required → 302 /signin instead of 500.
  • handleCallback: missing pending session (stale cookie) → 302 /signin instead of 500.
  • SessionService.acquireRefreshLease: PENDING (in-flight) login → 401 without clearing the session cookie, so a concurrent tab's refresh no longer breaks the login round-trip at the IdP.

Includes the regression test acquireRefreshLease_pendingLogin_returnsEmptyWithoutClearingCookieOrSession (SessionServiceTest 32/32 green on main).

Sibling PRs: main #31181, plus the 1.13 hotfix for the in-memory HttpSession architecture.

🤖 Generated with Claude Code

… pending logins (#30304)

- /callback with login_required/interaction_required/consent_required/
  account_selection_required: redirect to interactive /signin instead of 500.
  These are the IdP's spec-defined 'silent auth not possible' replies
  (e.g. prompt=none with no IdP session); a 500 loops the frontend.
- /callback with no pending session (stale/consumed cookie): redirect to
  /signin instead of 500 — the stale cookie is already cleared.
- acquireRefreshLease on a PENDING (in-flight) login: return empty (401)
  WITHOUT clearing the session cookie — a concurrent tab's refresh timer
  must not break the login round-trip at the IdP.

Root cause reproduced end-to-end on 1.13.1 + mock OIDC provider (issue #30304,
Okta confidential + offline_access): login -> concurrent refresh -> user
completes Okta -> callback fails -> loop. Test added for the pending-lease race.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@mohityadav766
mohityadav766 requested a review from a team as a code owner August 7, 2026 11:57
@github-actions

github-actions Bot commented Aug 7, 2026

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 backend safe to test Add this label to run secure Github workflows on PRs labels Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 6402e19068a7047f00c513f4929c78ee84b6907b in Playwright run 31216062570, attempt 1.

✅ 796 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 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) 48m 59s

⏱️ Max setup 3m 2s · max shard execution 17m 15s · max shard-job elapsed before upload 20m 16s · reporting 5s

🌐 209.87 requests/attempt · 2.66 app boots/UI scenario · 14.30% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 209.87 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.66 per UI scenario (2494 boots / 936 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 131 0 0 0 0 0
✅ Shard chromium-02 120 0 0 0 0 0
✅ Shard chromium-03 153 0 0 0 0 0
✅ Shard chromium-04 112 0 0 0 0 0
✅ Shard chromium-05 129 0 0 0 0 0
✅ Shard data-asset-rules-01 61 0 0 0 0 0
✅ Shard domain-isolation-01 14 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 10 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

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

…auth fallback

- handleCallback with no pending session now asserts the /signin redirect
  (was asserting the old 500), matching the login-loop fix
- add regression tests: login_required at callback redirects to /signin,
  non-silent errors still 500
- log silent-auth errors at WARN instead of ERROR (expected path)

Co-Authored-By: Claude Fable 5 <[email protected]>
@mohityadav766

Copy link
Copy Markdown
Member Author

closing will pick from main

@gitar-bot

gitar-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 2 resolved / 2 findings

Hardens OIDC authentication by adding interactive sign-in redirects for silent-auth errors and preserving pending logins during refresh lease acquisition, addressing both missing test coverage and outdated callback tests.

✅ 2 resolved
✅ Bug: Existing callback test not updated for new redirect behavior

📄 openmetadata-service/src/main/java/org/openmetadata/service/security/AuthenticationCodeFlowHandler.java:461-469
The pre-existing test handleCallback_noPendingSession_writesErrorResponse asserts verify(response).setStatus(SC_INTERNAL_SERVER_ERROR) and that the body contains "No pending session found for callback". The changed handleCallback now takes the new empty-pending-session branch: it logs a warning, calls resp.sendRedirect(serverUrl + "/signin") and returns, so it never sets a 500 status nor writes that body. This test was not updated in the diff (only SessionServiceTest.java was touched) and will now fail. Update the test to assert the redirect to /signin instead of the 500 error, and add a serverUrl stub if needed.

✅ Bug: No test coverage for SILENT_AUTH_ERRORS interactive fallback

📄 openmetadata-service/src/main/java/org/openmetadata/service/security/AuthenticationCodeFlowHandler.java:480-491
The new branch in handleCallback that redirects to /signin when the IdP returns login_required/interaction_required/consent_required/account_selection_required (lines 480-491) has no regression test, and the custom instructions require bug fixes to include a failing-test regression check. Add a unit test that drives an AuthenticationErrorResponse with one of the SILENT_AUTH_ERRORS codes and asserts a redirect to serverUrl + "/signin" (and one with a non-silent code asserting the 500 path is preserved).

Options

Display: compact → Showing less information.

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

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

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant