Skip to content

feat(auth): notify about unset FUSION_OIDC_ALLOWED_USER; derive OIDC redirect URI - #289

Merged
0x2E merged 1 commit into
mainfrom
feat/oidc-hardening
Nov 22, 2026
Merged

0x2E merged 1 commit into
mainfrom
feat/oidc-hardening

Conversation

@0x2E

@0x2E 0x2E commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Summary

Two OIDC follow-ups: a non-breaking notice for deployments without FUSION_OIDC_ALLOWED_USER (a future version will require it), and an optional FUSION_OIDC_REDIRECT_URI.

<Sidebar> (frontend/src/components/layout/sidebar.tsx)
  useAppInfo()            // GET /api/app -> { ..., notices: string[] }
  header: logo  "Fusion"  [CircleAlert]   // only when a known notice exists
                            └─ <Popover>  title + body per notice
 oidcLogin
-  AuthURL()                                  // fixed RedirectURL from env (required)
+  AuthURL(FUSION_OIDC_REDIRECT_URI || scheme://Host/api/oidc/callback)
+    store redirectURI with state
 oidcCallback
   Callback(state, code)
-    Exchange(code, code_verifier)
+    Exchange(code, code_verifier, redirect_uri = state.redirectURI)

The redirect URI used at the token exchange always comes from the stored state, never from the callback request. A spoofed Host only produces a URI the IdP rejects.

Closes #284

Evidence

  • Before: new tests on the old code fail: /api/app has no notices; OIDC without a redirect URI fails at startup (FUSION_OIDC_REDIRECT_URI is required…).
    After: ./scripts.sh test-backend and ./scripts.sh test-frontend pass; mutation checks (drop redirect_uri from the exchange, drop the [] init, ignore the configured URI, …) are all caught.
  • Release-style build with a fake IdP that checks PKCE and that the token redirect_uri equals the authorize one: OIDC login works with a derived URI (localhost and 127.0.0.1 Hosts, X-Forwarded-Proto: https) and with a configured one; changing Host at callback time has no effect.
  • Headless Chromium: icon present only when expected, accessible name, keyboard and Escape work, popover renders in all 8 locales and on a 390px viewport. Also tried manually in a browser.

Merge Danger

Door: two-way

Blast Radius: auth

  • frontend/src/components/ui/popover.tsx was generated by pnpm dlx shadcn@latest add popover, with one line changed: the upstream base-vega registry item imports cn from a package named cn (and adds it as a dependency). The import now uses @/lib/utils like the other components/ui files; the cn package was not added.
  • A whitespace-only FUSION_OIDC_ALLOWED_USER used to reject every account; it now counts as unset (any account can sign in, and the notice is shown).
  • Deployments that registered the legacy /oidc/callback path must keep setting FUSION_OIDC_REDIRECT_URI; the derived URI always uses /api/oidc/callback.
  • Behind a reverse proxy that does not forward the original Host and X-Forwarded-Proto, the derived URI is wrong and login fails at the IdP; setting the variable fixes it.

🤖 Generated with Claude Code

…redirect URI

Without FUSION_OIDC_ALLOWED_USER any account on the identity provider can
sign in to this single-user app. A future release will require it; this
release only warns, so existing deployments keep starting.

- GET /api/app returns notice codes (`notices`, always an array). The
  first code, oidc_allowed_user_unset, is set when OIDC is configured
  without an allowed user; a startup warning is logged too.
- The sidebar shows an alert icon next to "Fusion" when there are
  notices; clicking it opens a popover with the details (all locales).
- FUSION_OIDC_REDIRECT_URI is now optional. When unset, the callback URL
  is derived per login request from the scheme and Host, stored with the
  state and reused in the token exchange.
- A whitespace-only FUSION_OIDC_ALLOWED_USER now counts as unset.

The popover was added with the shadcn CLI. The upstream base-vega
registry item imports `cn` from a package named "cn"; the import was
changed to "@/lib/utils" and the extra dependency was not added.

Closes #284

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@0x2E
0x2E merged commit aa2bcd9 into main Nov 22, 2026
2 checks passed
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.

[FR] Add Default OIDC Redirect URL

1 participant