fix(audit): record real client IP behind Traefik #444
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/PMS-587-audit-client-ip"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Audit log entries recorded the socket peer address, which behind Traefik is the proxy rather than the client (rendering as
-in the audit page and CSV export). Resolve the real client IP from the X-Forwarded-For header, trusting it only when the peer falls inside a configured proxy CIDR so a spoofed header from a direct client cannot poison the recorded address. Mirrors Bunyip's extract_client_ip + TRUSTED_PROXY_CIDR handling.Adds src/utils/client_ip.rs with a pure, unit-tested extract_client_ip walking the forwarded chain right-to-left to the first untrusted hop, plus a TRUSTED_PROXY_CIDR allowlist (defaulting to loopback + RFC1918/ULA/link-local so a Docker/LAN Traefik works out of the box). Wires it into the AuditCtx request extractor (covers every entity-mutation audit row) and the three auth-side IP capture sites (login, logout, Google callback). Direct requests still record the peer and never panic on a missing or garbled header.
#PMS-587