Repository navigation
Closed
Description
Problem or outcome
The operable shell (#2, PR #1) serves health but has no way to initialize an installation or authenticate anyone. Implement the Milestone 1 authentication scope from docs/architecture.md: first-run setup with a short-lived setup code, local administrator creation in a single transaction, Argon2id password hashes, opaque server-side sessions in HttpOnly cookies, administrator-issued password reset codes, and sole-administrator recovery via OS access to the data directory. No email, no OIDC, no external services.
Scope
In scope:
- Migration 0002:
agency(single row),user,capability_grant,session,setup_code,password_reset_code,audit_event(append-only, trigger-enforced) - Capability-based authorization from the start (
manage_usersgates user administration); the Administrator role is a named grant bundle, per the domain model — no role-name comparisons - Setup: uninitialized installations emit a hashed, short-lived setup code at
servestartup (plus asetup-codecommand);POST /api/setupcreates agency settings + first administrator + grants and consumes the code in one transaction; setup is unavailable after initialization - Sessions:
POST /api/auth/login,POST /api/auth/logout,GET /api/auth/session; cryptographically random opaque tokens stored hashed at rest, HttpOnly + SameSite cookies, expiration and immediate revocation - Reset:
POST /api/auth/reset-codes(requiresmanage_users) issues a short-lived single-use code;POST /api/auth/resetforces a new password, revokes all sessions, and records an audit event - Recovery:
consolebook recover --username ...(OS access to the data directory) issues a reset code for an administrator and records an explicit recovery audit event - Audit events for authentication actions (login, logout, setup, reset issued/used, recovery), content-free per the logging rule
- ADR 0004 documenting the authentication decisions
- Integration tests for every flow, including failure paths
Out of scope:
- SvelteKit shell (separate slice)
- OIDC, SMTP (held until justified per roadmap)
- Coordinator/Trainer/Trainee capabilities beyond schema support (Milestone 3)
- Rate limiting / lockout policy (needs its own decision; noted in ADR)
Acceptance criteria
- An empty installation initializes end-to-end: setup code →
POST /api/setup→ login → authenticated session - Setup code is single-use, expires, and is refused after initialization
- Session tokens are opaque, hashed at rest, expire, and revoke immediately on logout and password reset
- Reset codes are single-use, short-lived, admin-issued (capability-checked), and using one revokes all sessions
-
recoverworks without any valid credentials but requires data-directory access, and records an audit event -
audit_eventrejects UPDATE and DELETE at the database level - All repository gates pass
Expected proof
cargo fmt --check && cargo clippy --workspace --all-targets -- -D warnings && cargo test --workspace- pr-gate green on the PR
Related roadmap, decisions, or issues
docs/roadmap.mdMilestone 1;docs/architecture.mdAuthentication / First-run setup;docs/domain-model.mdPeople and access, Audit- ADR 0001 follow-up list (authentication); builds on Adopt the ConaryLabs house repo contract and PR gate #2 / PR Implement Milestone 1 operable-shell foundation #1, meta(repo): adopt ConaryLabs house contract and PR gate #3
Metadata
Metadata
Assignees
Labels
No labels
Activity
auth(setup): first-run setup, sessions, and password recovery