fix(security): API token strength and brute-force lockout

- Refuse an API token under 24 characters or with whitespace at startup, without echoing it
- Lock an address out for 5 minutes after 10 wrong or missing tokens in 5 minutes (429 with Retry-After)
- Ignore X-Forwarded-For for the lockout, forget idle addresses
- Document both
This commit is contained in:
tgiachi 2026-11-09 20:25:05 +01:00
commit 625d487eca

View file

@ -213,6 +213,10 @@ lists.example.org lmtp:inet:127.0.0.1:2424
and `Reply-To` come from the header; so a post whose header names someone else (or has no usable `From`, or several
addresses) is held for moderation instead of delivered, with the reason shown to the admin (API, CLI, UI). Let Postfix
reject forged senders too (SPF, DKIM, DMARC checks on inbound mail).
- **API token.** `parsimony serve` refuses a token shorter than 24 characters or containing whitespace
(`openssl rand -hex 24` makes a good one). After 10 wrong or missing tokens within 5 minutes an address is
locked out for 5 minutes (HTTP 429, valid token included). The address is the TCP peer: behind a reverse proxy
every client shares the proxy's address, so rate-limit at the proxy as well.
- The API and the admin UI use one bearer token and no TLS: put them behind a reverse proxy with TLS and keep the `api`
listener private.