molecule-core/canvas/src/lib
Hongming Wang 575f893f4e fix(canvas): consume CP logout_url to break the SSO re-auth loop
Follow-up to molecule-controlplane#485. The first half of #2913 wired
a Sign-out button + signOut() helper that POSTed /cp/auth/signout, but
clicking still left the user signed in: WorkOS's browser cookie
preserved the SSO session, /cp/auth/login auto-re-authed via SSO, and
the user landed back on /orgs.

CP PR #485 returns the AuthKit hosted logout URL in the signout
response. This change has signOut() navigate the browser there
instead of /cp/auth/login. AuthKit clears its cookie + redirects to
return_to (configured server-side from APP_URL) → next /cp/auth/login
hits a fresh AuthKit, no SSO session, login form actually shows.

Defensive parsing: malformed JSON, missing logout_url, or wrong-type
logout_url all fall through to the legacy /cp/auth/login fallback,
which works locally (DisabledProvider, dev) where there's no SSO to
escape.

Forward-compat: when CP doesn't have #485 deployed yet, signOut()
sees logout_url="" or missing → fallback fires. Order of merge
between this and #485 doesn't matter, but the bug isn't actually
fixed end-to-end until both ship.

Tests added (3 new, 15 total auth.test.ts):
- Hosted logout: navigates to logout_url when response includes one.
- DisabledProvider path: falls back to /cp/auth/login when "".
- Defensive: malformed JSON body → fallback (no crash).
- Defensive: non-string logout_url → fallback (no open redirect).

Verified:
- npx vitest run src/lib/__tests__/auth.test.ts — 15/15 pass
- tsc --noEmit clean

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 12:21:49 -07:00
..
__tests__ fix(canvas): consume CP logout_url to break the SSO re-auth loop 2026-05-05 12:21:49 -07:00
api feat(canvas): SaaS cross-origin — slug header + cookie credentials (Phase F) 2026-04-14 20:08:39 -07:00
validation fix(ci): handle merge_group + shallow-clone BASE in secret-scan 2026-04-26 14:08:19 -07:00
api.ts Merge branch 'staging' into fix/canvas-multilevel-layout-ux 2026-04-26 00:36:54 -07:00
auth.ts fix(canvas): consume CP logout_url to break the SSO re-auth loop 2026-05-05 12:21:49 -07:00
billing.ts fix(canvas): apply flat-rate pricing copy for Phase 34 launch (Issue #1833) 2026-04-24 17:54:23 +00:00
canvas-actions.ts initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
credits.ts feat(canvas): warm-paper theme + Tailwind v4 migration 2026-05-03 01:43:55 -07:00
deploy-preflight.ts review: drop destructive Override + single-fetch configuredKeys 2026-05-01 13:40:58 -07:00
design-tokens.ts feat(canvas): render misconfigured workspaces with the configuration_status from agent_card 2026-05-04 15:14:40 -07:00
hydrate.ts initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
runtime-names.ts initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
runtimeProfiles.ts refactor(canvas): remove RUNTIME_PROFILES.hermes — value flows server-side now (#2054 phase 3) 2026-04-26 07:12:44 -07:00
services.ts refactor(secrets): strip Service dropdown from Add-Key form 2026-04-22 16:41:43 -07:00
tenant.ts fix(canvas): align tier text contracts with 4-tier reality (T1/T2/T3/T4) 2026-05-03 05:56:18 -07:00
theme-cookie.ts feat(canvas): warm-paper theme + Tailwind v4 migration 2026-05-03 01:43:55 -07:00
theme-provider.tsx feat(canvas): warm-paper theme + Tailwind v4 migration 2026-05-03 01:43:55 -07:00
theme.ts feat(canvas): warm-paper theme + Tailwind v4 migration 2026-05-03 01:43:55 -07:00
utils.ts chore(canvas): initialize shadcn/ui — components.json + cn utility 2026-04-18 07:57:17 -07:00
ws-close.ts fix(canvas): Legend avoids TemplatePalette + silence WS handshake races 2026-04-23 16:03:01 -07:00
ws-url.ts fix: code review findings — token UI, auth hardening, WS dedup 2026-04-16 10:42:26 -07:00