0031: A rotating sign-in code instead of a household password
Status: Accepted (owner, 2026-11-18: "Basically a rotating otp? Sounds peachy")
Context
ADR 0022 protected the LAN page (port 8970) with a household password of three words. On a real handheld it confused everyone: Settings showed new words each time (only A saved them), two homes showed two different "passwords", and nobody knew whether to type the spaces. The homes never need it themselves: pairing already made them the household's. Options: keep the password and show the current one on every home; or no password at all, a short code shown on a home, like Moonlight's own PIN.
Decision
The LAN page asks for a six-digit sign-in code. Settings on every home has a "Sign-in code" row; A opens a card with the current code, the page's address and a countdown. The runner makes the code from a key in household.json and the current minute (TOTP style); the code of the minute before also works, so one typed as it changes is not refused. A code works only while a home shows it (the card keeps a 90 s window open while it is up) or for 2 minutes after ./couchdogs code printed it on the host, the way in for a household with no screen at all. Sessions stay as in 0022 (30 days, signed by the runner's secret); X on the card signs out every browser. The wizard's password page becomes "Phone or laptop": the page's address and where the code is. The password, its words, ./couchdogs password and the page's "change password" go.
Consequences
- Nothing to remember or write down; a household with no TV uses any home, or the host command.
- Six digits are weaker than three words, but no one can guess while no screen shows a code, and the 0022 lockout (five wrong per address per minute) still holds.
- The code crosses the LAN in plain HTTP like the password did; it is dead a minute later.
- Any paired home can see the code: pairing already trusts it with the store and devices (ADR 0029 amendment).
- An old
household.jsonpassword entry is ignored and dropped on the next write; signed-in browsers stay signed in. - Supersedes the password part of ADR 0022; its LAN page, lockout and sessions stand.
Amendment (one sign-in per card, and a QR)
A sign-in spends the code it used: the window closes and the file records when (last_login), so every home showing the card closes it and says "Signed in from a browser" instead of leaving digits nothing accepts. A card's next poll says which sign-in it knew of, so it does not reopen the window the login closed; a card opened afterwards shows a fresh code that works. ./couchdogs code is the same: printed once, used once. The card also draws a QR code of the page's address with the code in the fragment (<web_url>/#code=123456), so a scan signs in without typing: a fragment never reaches the web service, and the page takes it out of the address before it posts the code. The card's hint names the page rather than device kinds (all homes are equal).