First-run setup for local mode (#51) #56
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/first-run-setup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bootstrap admin #1 for deployments without an IdP.
Flow: in local mode with no configured
auth.usersand an empty local-users store, cairnd generates a one-time token, prints it to the logs, and serves a branded/setuppage. The page creates the first admin (username + password ≥10 chars), which is persisted toauth.localUsersPath(default/data/.cairn/local-users.json), flagged admin, and logged straight in via a cookie session. Setup closes permanently once the first user exists.Security: the token is never exposed over HTTP (
GET /setup/statusreturns only{pending}), so "whoever races first" can't claim admin on a network-reachable instance; constant-time token compare;POST /setupreturns 409 once done.Pieces:
internal/auth/localstore.go— atomic-JSON store of runtime-created users.internal/auth/setup.go— the flow + endpoints; issues a session on success.Localprovider now merges store users with config users and setsUser.Adminfor store admins (so the bootstrap admin works over WebDAV/Basic too, not just the cookie).auth.admins.web/static/setup.html; configauth.localUsersPath.OIDC/LDAP deployments use
auth.adminGroupsinstead and are untouched (localUsersstays nil). Newsetup_test.gocovers the store + full flow (pending → wrong token → bad input → success → closed → conflict). gofmt/vet/build/test +node --checkgreen on the runner.