v1.0.0:4 — remove default admin@local credentials; require StartOS action to bootstrap

Security: shipping admin@local / workout123 as a default that the
operator was supposed-to-rotate-but-might-not is the kind of footgun
that turns into "default-credential exposure" headlines. Eliminated.

prisma/seed.ts now ONLY seeds the InstanceSettings singleton — no
admin user, no UserPreferences, no exercises in the build-time
fallback DB. The image still ships with prisma/exercises.seed.json
(curated 164-exercise library) but those rows aren't inserted until
an admin is created via the StartOS Action.

The change-admin-credentials Action now does INSERT-or-UPDATE in one
shot. CREATE mode (no admin exists) inserts the User row, inserts
UserPreferences with sensible defaults, and runs
ensureExerciseLibrary.cjs for the new admin so they don't have to
wait for the next service start to see the curated library. UPDATE
mode (admin exists) keeps the v1.0.0:1-3 rotation behavior. The
mode is auto-detected by counting `WHERE isAdmin = 1`.

The login page is now a server component that reads the admin count
upfront. Zero admins -> renders a "needs setup" panel pointing at
the StartOS Action ("Services -> Proof of Work -> Actions -> Set
admin credentials"). Otherwise renders the existing LoginForm
(extracted to LoginForm.tsx). Eliminates the
"I tried admin@local/workout123 and it failed, what's wrong"
fresh-installer confusion.

Backward compatible for upgrades from v1.0.0:1-3:
  - /data already has an admin user; the no-admin detection never
    triggers; login behaves identically to before.
  - The Action's UPDATE mode still works for rotation.

Version graph: v1.0.0:4 promoted to current; v1.0.0:1, :2, :3 all
listed as `other` for in-place upgrade paths.

README updated to call out the explicit no-default-account design
and how to bootstrap an admin in local dev (Prisma Studio, since
the StartOS action isn't available off-StartOS).
This commit is contained in:
Keysat
2026-05-09 19:13:49 -05:00
parent a64fee4873
commit 5f7b3b6b7a
8 changed files with 405 additions and 266 deletions
+13 -3
View File
@@ -22,14 +22,24 @@ cd proof-of-work
npm install
npx prisma generate # important after schema changes
npx prisma db push # create the dev DB at prisma/data/app.db
npm run db:seed # admin@local / workout123 + curated library + admin flag
npm run db:seed # ONLY seeds the InstanceSettings singleton — no admin
npm run dev # http://localhost:3000
```
For local dev you'll need to create an admin manually since the
StartOS action isn't available — easiest is `npx tsx` a one-off
script, or just open Prisma Studio (`npm run db:studio`) and add a
User row with `isAdmin: true` + a bcrypt hash you generate with
`node -e 'require("bcrypt").hash("yourpassword", 10).then(console.log)'`.
## Multi-user
Every install starts with one admin user (`admin@local`) and **sign-ups
closed**. To open the instance to additional users:
**Fresh installs ship with no admin user on purpose** — the operator
must run the StartOS Action `Set admin credentials` (Services → Proof
of Work → Actions) before anyone can log in. This eliminates the
default-credentials footgun.
Once the admin exists, they can open sign-ups for additional users:
- In-app: log in as admin -> **Settings -> Instance Settings ->
Allow new sign-ups**.