Skip to content

fix: harden OIDC auth without breaking existing configs - #406

Open
igoroctaviano wants to merge 4 commits into
masterfrom
feat/oidc-auth-hardening
Open

fix: harden OIDC auth without breaking existing configs#406
igoroctaviano wants to merge 4 commits into
masterfrom
feat/oidc-auth-hardening

Conversation

@igoroctaviano

@igoroctaviano igoroctaviano commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Harden OIDC on the existing oidc-client stack so current public configs (including grantType: "implicit") keep working with no config or IdP redirect URI changes.
  • Restore deep links after login via the OIDC state parameter (removes brittle slim_path / slim_search localStorage). Warm sessions no longer re-apply a stale return URL.
  • On DICOMweb 401: try silent renew first, then interactive login with return URL. The reauth guard stays set once an IdP redirect starts (avoids concurrent-401 races). After a successful in-page renew, routed views remount so failed requests refetch with the new token.
  • Silent renew reuses the already-registered app redirect URI; iframe callbacks (success or IdP errors like login_required) complete in index.tsx and never mount the React SPA, so they cannot corrupt parent OIDC sessionStorage.
  • Keep Authorization headers consistent; enable logout even without endSessionEndpoint (local session clear fallback).
  • isSafeReturnUrl / isOidcAuthorizeCallbackUrl helpers with unit tests.

Compatibility / non-regression

  • Still depends on oidc-client@^1.11.5 (not oidc-client-ts).
  • public/config/*.js unchanged; implicit and code response types both supported as before.
  • No new OAuth redirect URIs required at the IdP.
  • PKCE / oidc-client-ts migration intentionally deferred (would break implicit deployments).

Test plan

  • With an existing implicit config (grantType: "implicit"), open a deep study URL, log in, and confirm you return to the same study (not /).
  • Warm session: with a valid stored user, open / and confirm you are not redirected to a previous study URL.
  • Confirm auth query/hash params are cleared after the callback.
  • Force / wait for token expiry leading to 401s: silent renew refreshes and the view recovers without a full page reload when renew succeeds.
  • If silent renew fails (login_required), interactive login restores the current route; the renew iframe must not boot Slim; concurrent 401s should not start multiple IdP redirects.
  • Logout works with and without endSessionEndpoint.
  • Confirm public/config/*.js files are unchanged.

Migrate to oidc-client-ts with auth-code+PKCE by default while keeping
grantType: "implicit" working unchanged. Restore deep links via OIDC
state, add silent renew, and recover from 401 without dropping the route.
@deepsource-io

deepsource-io Bot commented Aug 3, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 93cdfbd...6d10814 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
JavaScript Aug 3, 2026 2:15p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 6d10814):

https://idc-external-006--pr406-feat-oidc-auth-harde-0za8mqbo.web.app

(expires Mon, 10 Aug 2026 14:18:22 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 88aacecd98ba54d2f9c8d201a9444e43d1ad8307

Drop the oidc-client-ts migration that broke grantType: "implicit".
Retain state-based deep-link restore, safer 401 renew, and silent renew
via the existing redirect_uri with an iframe bootstrap path.
Keep the interactive reauth guard set after IdP redirect starts so
concurrent 401s cannot overwrite OIDC state, and remount routed views
after silent renew so failed requests refetch with the new token.
Detect IdP error callbacks (e.g. login_required) as renew iframe
responses and skip React mount so the iframe cannot corrupt parent
OIDC sessionStorage during interactive re-auth fallback.
@sonarqubecloud

sonarqubecloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

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