Extract the session layer behind an AuthProvider contract in @wasp.sh/auth-contract - #4725
Extract the session layer behind an AuthProvider contract in @wasp.sh/auth-contract#4725FranjoMindek wants to merge 1 commit into
Conversation
Deploying wasp-docs-on-main with
|
| Latest commit: |
c06e4b2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c55e83f2.wasp-docs-on-main.pages.dev |
| Branch Preview URL: | https://franjo-auth2-2-auth-contract.wasp-docs-on-main.pages.dev |
91585e6 to
e56cc25
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: |
e56cc25 to
6784eb5
Compare
|
Two contract refactors landed in this revision:
|
6784eb5 to
776ce92
Compare
|
Third contract refinement: |
776ce92 to
2ced327
Compare
|
Final contract shape, per review discussion: capabilities are now pure mixins, not an inheritance chain. |
2ced327 to
c06e4b2
Compare
c06e4b2 to
9ff7043
Compare
|
This pull request is now stale. Next steps if the PR is still relevant, and you are able to devote time to it:
If no action is taken, this PR will be automatically closed in 7 days. |
Description
Stack 2/7. Extracts Wasp's session layer behind an
AuthProvidercontract, born in its final home and final shape: the@wasp.sh/auth-contractnpm package (a generator lib, shipped into apps as a tarball).The contract is small and final — nothing later in the stack rewrites it, only extends it:
VerifiedSession { sessionId, subjectId, claims? }— verify, don't fetch: a provider turns a credential into an identity; it is deliberately notfindById.AuthProvider { id, authenticate(request: Request), revokeSession }— a standard webRequest; for websockets Wasp synthesizes one carrying only the bearer header.SessionIssuingAuthProvider { issueSession, revokeAllSessions }+canIssueSessions()— session establishment is a capability, not part of the base interface (Clerk has no server-side login at all).session.tsnow talks only to the interface; Wasp's own Lucia-backed auth becomes its first implementation (provider/wasp.ts). Nothing else changes hands: middleware, websocket handler and logout route are untouched consumers.Three deliberate behavior changes to scrutinize, all prerequisites for later JIT provisioning:
findFirstkeyed by auth id) — same query count, the shape every provider needs.null) instead of throwing.createSessionreturns{ id }instead of a LuciaSession;wasp/server/auth/session(PRIVATE API) signatures change accordingly.The adapter-package surface (
ServerAdapterFactoryetc.) deliberately arrives in stack 6/7 together with its consumers. There is intentionally no client-side contract: an adapter's client side ships as ordinary React exports on its own/cliententry, and Wasp generates no client glue (design note for a future generated-glue iteration: aWrappercomposition slot, pull-basedgetCredential(),onCredentialChangefor websocket re-auth,onLogout— deferred until real consumers exist).Review guidance: the contract +
session.ts+provider/wasp.tsare the substance (~600 lines); skip goldens and the@wasp.sh/auth-contractlockfile entries in example lockfiles.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.