Harden sign-in: __Host- session cookie and a per-email login lock

- The session cookie is __Host-ngu_session when Secure (production),
  so a sibling subdomain can't set or overwrite it; plain ngu_session
  over local http. Every admin signs in again once after deploying.
- Five wrong passwords for one email lock that email for 15 minutes,
  from any address; a correct password clears it. On top of the
  per-IP limit.
- CLAUDE.md: noImplicitAny stays off on purpose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-29 02:11:57 -05:00
parent d1a6332a45
commit b165e612c2
5 changed files with 83 additions and 5 deletions

View file

@ -43,6 +43,19 @@ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Both lines are already in every proxied block in `nginx-dev` and in
`docs/seo.md`.
## Sign-in
- The session cookie is `__Host-ngu_session`: the browser only
accepts it Secure, on path `/`, with no Domain, so another
subdomain can't set or overwrite it. With `COOKIE_SECURE=false`
(plain-http local work) it's `ngu_session`, since the prefix needs
Secure.
- Logins are limited per IP where `/api/auth/login` is mounted (10
per 15 minutes, `server/src/index.js`) and per email in
`routes/auth.js`: five wrong passwords for one address lock it for
the rest of 15 minutes, from anywhere; a correct one clears the
count. Both are in memory and reset when the service restarts.
## From nginx: HSTS
nginx terminates TLS and serves files from disk (`/assets/`,