Make app.auth.provider a required discriminated union: waspAuth() or an external provider manifest - #4726
Conversation
Deploying wasp-docs-on-main with
|
| Latest commit: |
ed34ccc
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://67456a2c.wasp-docs-on-main.pages.dev |
| Branch Preview URL: | https://franjo-auth2-3-spec-provider.wasp-docs-on-main.pages.dev |
d4fccef to
4fa8644
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: |
4fa8644 to
36c80e7
Compare
|
Follow-up to the contract change in #4725: |
36c80e7 to
f75f6ed
Compare
f75f6ed to
0d133ef
Compare
| }, | ||
| onAuthFailedRedirectTo: "/login", | ||
| onAuthSucceededRedirectTo: "/", | ||
| // Wasp's own auth, selected explicitly. Everything that only makes sense |
There was a problem hiding this comment.
These comments are unnecessary.
Also remove the original ones from the first PR.
Maybe just leave a short TODO: to be replaced with better-auth adapter e.g. in correct example.
This is true for all examples.
| -- independently of Wasp releases, so a closed enum here would break decoding of | ||
| -- every manifest built against a newer adapter. Unknown entries are ignored. | ||
| data ExternalAuthProviderSpec = ExternalAuthProviderSpec | ||
| { -- | Stable identifier ("clerk", "better-auth"). Identities Wasp provisions |
There was a problem hiding this comment.
Update to follow external convention
| serverPackage :: Maybe String, | ||
| -- | User-code module implementing the provider (the hand-written adapter | ||
| -- escape hatch), reached through a virtual user module like every other | ||
| -- ext import. | ||
| serverModule :: Maybe ExtImport, |
There was a problem hiding this comment.
If these are exclusive make them Either
| -- | Populates the user entity when Wasp provisions a local user for a | ||
| -- subject it has not seen before. | ||
| userSignupFields :: Maybe ExtImport, | ||
| -- | Setup function for the provider's underlying library (the |
There was a problem hiding this comment.
Please remove reudundant information like @prismaSetupFn@ convention.
Keep field descriptions minimal.
| // pattern would rewrite it into `provider: SMTP({...})` and corrupt the spec. | ||
| const waspSMTPAppSpec = waspTsSpec.replace( | ||
| /provider:\s+[A-Za-z0-9_][A-Za-z0-9_]*/g, | ||
| /provider:\s+(SMTP|SendGrid|Mailgun|Resend|Dummy)\b/g, |
There was a problem hiding this comment.
We replace SMTP with SMTP?
…an external provider manifest
0d133ef to
ed34ccc
Compare
|
Review fixes applied:
|
Description
Stack 3/7. The semantic heart of the feature:
app.auth.providerbecomes a required discriminated union —waspAuth({ methods, onAuthSucceededRedirectTo, ...hooks })for Wasp's own auth, or an external provider manifest (produced by an adapter package's spec helper orcustomAuthProvider()).@wasp.sh/spec): the union,waspAuth(),defineAuthProviderManifest()with validation invariants,customAuthProvider(). Everything that only makes sense when Wasp runs signup/login (methods, hooks, success redirect) moves offAuthintowaspAuth(), so none of it can leak into an external-provider app.id,server(package entry or user-code module ref),routes,capabilities(open string set),env(server+client var requirements with docs),userSignupFields,setupFn,options,contractVersion.AuthProvider = WaspAuthProvider WaspAuthConfig | ExternalAuthProvider ExternalAuthProviderSpec, hand-written kind-discriminated JSON codecs,HasCustomEvaluation, accessor shims so the generator compiles unchanged.waspAuth()(kitchen-sink, tutorials, waspello, websockets, ask-the-documents, the basic starter, and all four auth example apps) — this is exactly the migration the union imposes on users.Auth+Experimentalsections).The generator does not consume external manifests yet: they are legal but inert until stacks 4-6. Mapper acceptance of
server: { package }entries is likewise latent until 6/7.Review guidance: spend the effort on
waspSpec.ts,constructors.tsandAuth.hs(~800 lines); the per-appwaspAuth()wraps are mechanical and identical.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.