Repository navigation
feat(dashboard): use the official auth/DB foundation (#547 phase A) - #642
Merged
Merged
Conversation
New Dashboard projects now compose the OFFICIAL `sv add drizzle better-auth` integrations instead of SVForge-generated copies. SVForge keeps only its product/security extensions. Ownership split: - `svforge create` runs `sv add drizzle="database:postgresql+client:postgres.js"` and `sv add better-auth="demo:"` before the SVForge add-on (single install). Direct `sv add svforge=template:dashboard` now fails loudly until the official add-ons are present; this limitation is documented (#547 phase C). - The dashboard template no longer ships auth.ts, db/index.ts, db/auth.schema.ts, auth.schema.config.ts, drizzle.config.ts, hooks.server.ts, app.d.ts, env.ts or .env.example. `.env`/`.env.example`, `db/schema.ts` (domain tables + `export * from './auth.schema'`) and scripts stay SVForge. - SVForge applies anchored, idempotent patches to the official output: `...svforgeAuthPolicy` before plugins plus the sign-up mode on the official `emailAndPassword`, `sequence(handleParaglide, handleBetterAuth, handleSvforgePolicy)`, `SIGNUP_MODE` in env.ts/.env/.env.example. Missing anchors fail the scaffold loudly. Security behavior unchanged: closed-by-default sign-up (invite/self-service explicit), `role`/`disabled` via Better Auth `additionalFields` (input:false, generated NOT NULL by the official `auth:schema`), server-side invite gate and session rejection for disabled identities, atomic first-admin bootstrap. Tooling: - remove the Better Auth pin, its rewriter and pin tests; the security audit resolves the range declared by the installed `sv` (`better-auth-version.mjs`). - `auth:schema` is the official generator; scaffold profiles run it before the DB push/build (the generated stub is not type-safe before that). - Prettier ignores the official/generated artifacts it does not format (tsconfig.json, src/env.ts, auth.schema.ts, drizzle/). - schema gate accepts the official double-quoted output and `.defaultNow()`. Validated: full repo suite, lint, typecheck; `test-scaffold.sh base`, `dashboard` (46 tests, schema gate, Better Auth HTTP smoke, closed sign-up) and `create-cli` (all 13 modules, 58 tests) with real PostgreSQL. Refs #547 (phase A; Paraglide and direct-add orchestration remain).
Merged
This was referenced Oct 23, 2026
Merged
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.
Phase A — official auth/DB foundation
New Dashboard projects now use the official
sv add drizzle better-authintegrations; SVForge only composes its product/security extensions on top. Base projects are unchanged, existing projects are not migrated.Ownership split
auth:schema, Drizzle client/config, versionsrole/disabled(additionalFields,input:false), disabled-session guard, domain tables, admin UI/scriptssvforge createnow runssv add drizzle="database:postgresql+client:postgres.js+docker:no"andsv add better-auth="demo:"before the SVForge add-on (single install at the end).auth.ts,db/index.ts,db/auth.schema.ts,auth.schema.config.ts,drizzle.config.ts,hooks.server.ts,app.d.ts,env.ts,.env.example....svforgeAuthPolicybeforeplugins+ signup mode on the officialemailAndPassword;sequence(handleParaglide, handleBetterAuth, handleSvforgePolicy);SIGNUP_MODEinenv.ts/.env/.env.example. A missing anchor fails the scaffold loudly.Security behavior (unchanged)
Closed-by-default sign-up (
closed/invite-only/self-serviceexplicit),role/disabledgenerated NOT NULL by the officialauth:schema(additionalFields,input:false), server-side invite gate, disabled identities rejected at session creation and on live sessions via the composed guard, atomic first-admin bootstrap.Tooling
sv(scripts/better-auth-version.mjs) — CI/publish workflows updated.auth:schemais the official generator and now runs in the scaffold profiles before the DB push/build (the delivered stub is not type-safe before that);svforge createnext-steps document the order.tsconfig.json,src/env.ts,src/lib/server/db/auth.schema.ts,drizzle/).check-auth-schema.mjsaccepts the official double-quoted output and.defaultNow().Checks
bun run test(whole repository),bun run lint,bun run typecheck,node scripts/check-generated.mjs— pass.bash scripts/test-scaffold.sh base— pass (unchanged base).bash scripts/test-scaffold.sh dashboard(CI=true, disposable PostgreSQL 17) — pass: build, svelte-check, generated ESLint/Prettier,svforge check, 46 template tests, schema↔runtime gate, Better Auth HTTP smoke (setup → closed sign-up rejected → login → admin CRUD → user B sign-in/denied admin).bash scripts/test-scaffold.sh create-cli— pass:svforge createbase + all-13-modules dashboard, doctor/check clean, build, 58 tests, real PostgreSQL.Limitations (by design for phase A)
sv add svforge=template:dashboardfails with an actionable message: the publishedsvcannot conditionally depend on the official add-ons from the dashboard option (phase C, upstream conditionaldependsOn).hooks.server.tsis therefore composed by SVForge around the official auth handle.Refs #547 — phase A only, issue stays open.