mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-12-01 00:49:33 +01:00
docs(auth): list the no-header step after the Basic check; changeset
The pipeline list said it "runs in this order" but put the no-header challenge before the HTTP Basic check, while single-user auth.ts checks the correct password first. Swap steps 3 and 4. Note in the README and the Security / Remote-Access wiki pages that a request with no credentials is never counted, and add the patch changeset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ad08cb957d
commit
cc2b7d9c25
5 files changed
+20
-12
No files matched your search
@@ -136,15 +136,16 @@ loopback bind matters. The auth pipeline (`src/web/middleware/auth.ts`,
|
||||
so misfiring hooks can never lock out the login path.
|
||||
2. **Session cookie** check — a valid `codeman_session` cookie short‑circuits to
|
||||
allow.
|
||||
3. **No `Authorization` header** — return `401` with the `WWW-Authenticate`
|
||||
challenge, **without counting it** and even while the IP is locked out (both
|
||||
modes; in multi-user mode this comes before the pre-verify gates). Such a
|
||||
request is no guess and runs no password check. Counting it let an open tab's
|
||||
background requests after a restart (cookie sessions live in memory) fill the
|
||||
bucket in seconds, and a `429` carries no challenge, so the browser never showed
|
||||
its login dialog again.
|
||||
4. **HTTP Basic** check — correct credentials short‑circuit to allow and clear
|
||||
3. **HTTP Basic** check — correct credentials short‑circuit to allow and clear
|
||||
that IP's failure counter.
|
||||
4. **No `Authorization` header** — return `401` with the `WWW-Authenticate`
|
||||
challenge, **without counting it** and even while the IP is locked out (both
|
||||
modes; in multi-user mode this comes before the pre-verify gates and the
|
||||
verify, which a missing header could never pass). Such a request is no guess
|
||||
and runs no password check. Counting it let an open tab's background requests
|
||||
after a restart (cookie sessions live in memory) fill the bucket in seconds,
|
||||
and a `429` carries no challenge, so the browser never showed its login dialog
|
||||
again.
|
||||
5. **Rate‑limit gate** — if the credentials did not pass and the IP is locked
|
||||
out, return `429` with a `Retry-After` header.
|
||||
6. Otherwise (wrong credentials, or an `Authorization` header that is not valid
|
||||
@@ -160,7 +161,8 @@ by presence in a server‑side map, so they cannot be forged offline.
|
||||
### Rate limiting / lockout recovery
|
||||
|
||||
Failed logins are tracked **per IP**: 10 failures (`AUTH_FAILURE_MAX`) → `429`, with a 15‑minute decay. Multi-user mode replaces that with three buckets, all with the same decay: a wider per-IP **pre-gate** of 50 failures (`AUTH_IP_FAILURE_MAX`), checked before the scrypt verify, which bounds scrypt cost from one source and tolerates many users behind one egress IP; a **per-(username, IP)** gate of 10 failures (`AUTH_FAILURE_MAX`), also checked before the verify, which is what caps verified guesses against one account from one source; and a **per-username** bucket, checked after the verify, that answers `429` to failed guesses from the 10th on, from any IP (the count is incremented before the check). The last two exist in multi-user mode only. So the wider per-IP cap does not widen guessing against any one account from one IP, and other IPs cannot lock an account out.
|
||||
The QR path has its own separate limiter.
|
||||
A request with no `Authorization` header is never counted (step 4), so an open
|
||||
tab after a restart cannot fill any bucket. The QR path has its own separate limiter.
|
||||
|
||||
The lockout check sits **after** the cookie/credential checks (step 5, not first).
|
||||
This is deliberate: a user with a **valid cookie or correct password recovers
|
||||
|
||||
Reference in new issue
Block a user