Phase 10, part 3: signing in and out, resets, locks and two-factor
The server edition now starts. Sign-in by email and password, limited per address and per IP; ten failures in a row lock the account and email its owner, and a reset by email (or an admin) unlocks it. Settings → Your account has the profile, the password, where you're signed in, and two-factor sign-in with an authenticator app (TOTP, from a QR code) and ten recovery codes. The app's own mail goes through SUPERMARKET_MAIL_URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2203,6 +2203,42 @@ This makes the server edition usable by a team. A commit after each part.
|
||||
- The server edition still won't start (`config.Ready`): signing in comes
|
||||
in part 3.
|
||||
|
||||
**Part 3 built 2026-11-25** on `phase10`. **The server edition now
|
||||
starts** (multi-tenant still doesn't).
|
||||
- `/signin`, `/signout`, `/forgot`, `/reset/<token>`, without the sidebar.
|
||||
A wrong password and an unknown address get the same answer, in the
|
||||
same time (a dummy Argon2 check); only with the right password does the
|
||||
page say an account is locked, turned off, or out of the team. `next`
|
||||
is followed only to a path in the app.
|
||||
- Limits (schema 34, a `throttle` table, so every copy of the app shares
|
||||
them): 5 failures per address and 20 per IP in 15 minutes, then sign-ins
|
||||
from them wait out the window. 10 failures in a row lock the account and
|
||||
email its owner; resetting the password (which proves the email) or an
|
||||
admin unlocks it. A wrong current password on Your account counts too.
|
||||
- Reset links (an hour, once) are emailed in the background, the same page
|
||||
shown whether or not there's an account; 3 per address and 10 per IP in
|
||||
15 minutes. A reset ends every session; signing in after still asks for
|
||||
the two-factor code.
|
||||
- `internal/appmail` sends the app's own mail through
|
||||
`SUPERMARKET_MAIL_URL` (STARTTLS required, or smtps).
|
||||
- Settings → Your account (every signed-in user): name, title, time zone;
|
||||
password (needs the current one, ends the other sessions); where you're
|
||||
signed in (browser, IP, when), signing out one or all the others.
|
||||
- Two-factor: TOTP (SHA-1, 6 digits, 30 s, a step either side), set up
|
||||
from a QR code (`rsc.io/qr`, a `data:` PNG) or the key typed in, and
|
||||
confirmed by a code before it's on. The secret is in the secrets store
|
||||
(`totp:<id>`, encrypted on the server), never in the users table. Each
|
||||
code works once (the last step is kept). Ten recovery codes
|
||||
(`xxxx-xxxx-xxxx`, kept as SHA-256s), each once; new ones, and turning
|
||||
it off, need the password. Sign-in with it on is two steps: the password,
|
||||
then the code, joined by a 5-minute one-time link. Fewer than 3 codes
|
||||
left: told so after signing in. The admin's reset comes with Users
|
||||
(part 4).
|
||||
- The sidebar shows who's signed in, with *Sign out*. An hourly job
|
||||
(`job:accounts`) forgets ended sessions, links and old counts.
|
||||
- Sign-ins, failures, locks, resets and two-factor changes are logged;
|
||||
they move to the audit log in part 8.
|
||||
|
||||
1. **Users and sessions.**
|
||||
- Tables:
|
||||
- `users`: email, name, kind (person or agent), status (invited,
|
||||
|
||||
Reference in New Issue
Block a user