Hash the web password and revoke sessions server-side

Store a scrypt hash (migrating a plaintext password without changing it),
sign sessions with a generation that ./password and --revoke-all rotate,
make logout a same-origin POST that revokes the token, add sign out everywhere,
and close proxied websockets whose session ends. Enforce a strength rule for
new passwords, back off logins per client and server-wide, check Origin on
login, tighten next, add security headers and a __Host- cookie over https.
This commit is contained in:
2026-11-10 01:21:28 +00:00
parent f11ff8650d
commit e43f9fa50c
17 changed files with 1353 additions and 125 deletions
+6 -3
View File
@@ -27,11 +27,14 @@ test("atomic password updates take effect without restart and fail closed on inv
const cookie = first.headers.get("set-cookie").split(";")[0];
await writeFile(auth + ".next", JSON.stringify({ ...data, password:"new-password" })); await rename(auth + ".next",auth);
assert.equal((await login("old-password")).status,401);
assert.equal((await login("new-password")).status,303);
assert.equal((await fetch(base + "/login", {headers:{Cookie:cookie},redirect:"manual"})).status,302);
const second = await login("new-password"); assert.equal(second.status,303);
// A changed password signs the earlier session out; the new one is signed in.
assert.equal((await fetch(base + "/login", {headers:{Cookie:cookie},redirect:"manual"})).status,200);
const cookie2 = second.headers.get("set-cookie").split(";")[0];
assert.equal((await fetch(base + "/login", {headers:{Cookie:cookie2},redirect:"manual"})).status,302);
await writeFile(auth + ".next", "malformed"); await rename(auth + ".next",auth);
assert.equal((await login("new-password")).status,503);
assert.equal((await fetch(base + "/login", {headers:{Cookie:cookie},redirect:"manual"})).status,503);
assert.equal((await fetch(base + "/login", {headers:{Cookie:cookie2},redirect:"manual"})).status,503);
await writeFile(auth,JSON.stringify(data));
assert.equal((await login("old-password")).status,303);
});