Skip to content

cloud: end the WorkOS session on sign out#1446

Merged
RhysSullivan merged 1 commit into
mainfrom
fix/workos-logout-session
Jul 21, 2026
Merged

cloud: end the WorkOS session on sign out#1446
RhysSullivan merged 1 commit into
mainfrom
fix/workos-logout-session

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

Fixes #1445.

Sign out cleared only the local sealed-session cookie; the hosted AuthKit session survived, so clicking Sign in again silently re-authenticated without credentials.

This follows WorkOS's documented sign-out flow:

  • WorkOSClient.logoutUrl unseals the cookie locally and plain-decodes the access token for the sid claim (no signature verification, so an expired token still signs out), then builds the logout URL with the SDK's URL builder. No network call.
  • The logout handler 302s through the WorkOS session-end endpoint, which ends the hosted session and returns to the public homepage. If the cookie won't unseal there is no session to end upstream, so it falls back to the old redirect-to-/; local cookies clear either way.
  • The shell submits sign-out as a top-level form POST instead of a fetch, so the redirect chain runs as a browser navigation carrying WorkOS's cookies.

Verification: full cloud e2e green (181 passed / 10 skipped) against @executor-js/emulate 0.13.6, which adds the emulator's /user_management/sessions/logout route (revokes the session; its refresh token stops working, matching real WorkOS). The logout scenario now follows the redirect through the emulator and asserts the session id is ended upstream; the auth-hint scenario signs out through the real account menu.

Deploy note: the production WorkOS dashboard needs its default sign-out redirect set to https://executor.sh/ (and the app's return_to registered) before this merges, or users land on a WorkOS default page after logout.

Logout only cleared the local sealed-session cookie; the hosted AuthKit
session survived, so the next Sign in silently re-authenticated without
credentials (#1445). Follow WorkOS's documented sign-out: extract the
session id from the sealed cookie locally (plain JWT decode, no
verification, so an expired token still signs out), 302 through the
WorkOS logout endpoint to end the session upstream, and land back on
the public homepage via return_to. If the cookie will not unseal, fall
back to the old redirect-to-/ so local sign-out always completes.

The shell submits sign-out as a top-level form POST instead of fetch so
the browser navigation carries WorkOS's cookies through the hop.

Needs @executor-js/emulate 0.13.6 (the emulator's session-end route).
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 21, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing 00a1502 Commit Preview URL

Branch Preview URL
Jul 21 2026, 06:18 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 21, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 00a1502 Jul 21 2026, 06:20 PM

@RhysSullivan
RhysSullivan marked this pull request as ready for review July 21, 2026 18:18
@RhysSullivan
RhysSullivan merged commit c53e6f8 into main Jul 21, 2026
15 of 17 checks passed
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Torn down — the PR is closed.

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.

Sign out does not terminate WorkOS session

1 participant