Mint Wasp sessions for external auth providers, with dual sign-out - #4764
Draft
FranjoMindek wants to merge 1 commit into
Draft
Mint Wasp sessions for external auth providers, with dual sign-out#4764FranjoMindek wants to merge 1 commit into
FranjoMindek wants to merge 1 commit into
Conversation
FranjoMindek
had a problem deploying
to
fly-deploy-test
August 25, 2026 14:08 — with
GitHub Actions
Failure
FranjoMindek
had a problem deploying
to
railway-deploy-test
August 25, 2026 14:08 — with
GitHub Actions
Failure
FranjoMindek
force-pushed
the
franjo/auth2-8-session-exchange
branch
from
August 25, 2026 14:15
4b8744f to
fde8c7d
Compare
@wasp.sh/spec
@wasp.sh/wasp-cli
@wasp.sh/wasp-cli-darwin-arm64-unknown
@wasp.sh/wasp-cli-darwin-x64-unknown
@wasp.sh/wasp-cli-linux-arm64-glibc
@wasp.sh/wasp-cli-linux-x64-glibc
@wasp.sh/wasp-cli-linux-x64-musl
commit: |
FranjoMindek
force-pushed
the
franjo/auth2-8-session-exchange
branch
from
August 27, 2026 18:41
fde8c7d to
4f18133
Compare
15 tasks
…th dual sign-out on logout
FranjoMindek
force-pushed
the
franjo/auth2-8-session-exchange
branch
from
August 27, 2026 19:02
4f18133 to
75b8dcb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the pluggable auth provider stack (9/9, on top of #4730).
Description
Wasp now mints its own first-party session for external auth providers, the way Rails, Django, and ASP.NET Core do it. The provider is consulted exactly twice:
POST /auth/loginexchanges the provider's credential (Clerk token, Better Auth token) for a Wasp session, JIT-provisioning the local user in the same step. Every subsequent request authenticates against Wasp's ownSessionrow — the provider is off the request hot path, so per-request latency and provider outages no longer touch request auth.SignOut(and laravel/workos). Wasp always revokes its own session, and — where the provider implementsSupportsSessionRevocation— best-effort revokes the provider session the login was exchanged from (its id is stored on the Wasp session row in the new nullableproviderSessionIdcolumn). Upstream failure is logged, never blocks logout. A logout inside the provider's own UI also ends the Wasp session (the client adapter observes the credential disappearing).The session machinery behind all this is extracted into
wasp/server/auth/sessionStore— Wasp's own create/validate/revoke API, with lucia as the private implementation detail behind one module (also the seam for migrating off the deprecated lucia later).waspAuthProviderand the exchange both sit on it, so Wasp's own auth and external providers now share one session layer, oneSessiontable, and one logout path.Client side: apps with a client adapter get the exchange automatically (single-flight, on the first API call after a provider login); hand-written integrations call the new public
exchangeCredentialForSession(credential).Documented, accepted gap (shared by every framework that mints its own sessions; it is why OIDC has four logout specs): revoking a session on the provider's side does not end an already-exchanged Wasp session — it lives until expiry or app logout.
session.tsand the example READMEs state this explicitly.Verified live with the Better Auth example: exchange mints a
Sessionrow pointing at the BA session; the BA token no longer authenticates requests directly (401);POST /auth/logoutdeletes both rows; the old Wasp session and a re-exchange of the revoked BA token both 401. Seeexamples/auth-providers/better-auth/README.mdfor the transcript.Existing apps need a
wasp db migrate-devfor the additive nullable column (migrations included for all four example apps).Type of change
Checklist
I tested my change in a Wasp app to verify that it works as intended.
🧪 Tests and apps:
examples/kitchen-sink/e2e-tests.waspc/data/Cli/templates, as needed.examples/, as needed.examples/tutorials) I updated the tutorial in the docs (and vice versa).📜 Documentation:
web/docs/.🆕 Changelog: (if change is more than just code/docs improvement)
waspc/ChangeLog.mdwith a user-friendly description of the change.web/docs/migration-guides/.versioninwaspc/waspc.cabalto reflect the changes I introduced.