Commit 35df946
committed
docs(admin): scope Audit middleware coverage to the protected chain
Codex P2 on the latest review of #674: the audit-log section
said the Audit middleware "is emitted for every non-GET/HEAD/
OPTIONS request that reaches the admin mux on this node,
regardless of which handler served it." That overstates coverage:
- `/auth/login` is wired through `publicAuth`, not `protect` —
the middleware can't identify the actor without a pre-existing
session, so it is intentionally skipped. AuthService emits
`admin_audit action=login` directly (auth_handler.go:432).
- `/auth/logout` is wired through `protectNoAudit` — the
middleware is omitted to avoid emitting two audit lines per
logout (a generic one plus the action-specific one); the
specific line is the one operators want (auth_handler.go:442).
- The `protect` chain is `BodyLimit → SessionAuth → Audit →
CSRFDoubleSubmit → handler` (server.go:247-255). Audit only
fires AFTER SessionAuth accepts the session, so an
unauthenticated write attempt (missing / expired / invalid
cookie) gets 401'd before reaching Audit and produces no
middleware line. CSRF-rejected requests still produce one,
by design, because the actor is known by then.
An operator building log-monitoring on top of the previous text
could conclude that every write attempt is guaranteed to
appear in `admin_audit`, then miss CSRF-bypassing probes
against an unauthenticated endpoint.
Rewrote the middleware-shape section to:
- Scope the rule to the protected mux chain.
- Explain the ordering choice (Audit between SessionAuth and
CSRFDoubleSubmit) so the CSRF-rejection-still-audits guarantee
is preserved in the doc.
- Enumerate the two auth endpoints that bypass the middleware
and what they emit instead.
- Adjust the intro paragraph: protected-chain mutations produce
two audit lines, auth endpoints produce one (was: "every
state-changing request typically produces two").
No behaviour change; doc-only. Verified against
internal/admin/server.go:236-296 and
internal/admin/auth_handler.go:432-449.1 parent 0813968 commit 35df946
1 file changed
Lines changed: 31 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
207 | 227 | | |
208 | 228 | | |
209 | 229 | | |
| |||
0 commit comments