Sign-in lockout with console unlock, and forgotten-password reset
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 29s

- Wrong passwords in a row are counted across every device and kept in
  the database. The first 3 are free; from the 3rd the next attempt
  waits 15 s, 30 s, 1, 2, 5, 15 and 30 minutes; the 10th locks sign-in
  until the unlock code printed to the server log (and saved to
  unlock-code.txt) is entered. Signed-in devices keep working. Only one
  password check runs at a time, so parallel guesses cannot skip a wait.
- "Forgot password?" prints a reset code to the log (reset-code.txt),
  valid once for 15 minutes. It sets a new password, signs out every
  device, lifts any lockout and signs in. Asking again while a code is
  valid prints nothing new.
- Codes are stored hashed; wrong codes count toward the per-address
  limit. RESET_ADMIN_PASSWORD also lifts a lockout.
- Sign-in page: a live countdown during a wait, an unlock step and a
  reset step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-11-16 15:46:16 -07:00
parent fe94dbf876
commit 917954d12d
7 changed files with 522 additions and 18 deletions

View file

@ -21,7 +21,7 @@ describe('authentication', () => {
it('requires the setup code, then a session, for private routes', async () => {
const fresh = await createTestApp({ login: false });
try {
expect((await fresh.api('GET', '/api/auth/status')).body).toEqual({ configured: false, authenticated: false });
expect((await fresh.api('GET', '/api/auth/status')).body).toEqual({ configured: false, authenticated: false, locked: false, retryAfter: 0 });
expect((await fresh.api('GET', '/api/classes')).status).toBe(401);
const bad = await fresh.api('POST', '/api/auth/setup', { code: 'WRONG-CODE', password: PASSWORD });
expect(bad.status).toBe(403);