feat(web): resolve real client IP behind a trusted reverse proxy #102
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/VS-83-trusted-proxy-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?
Add a system-level trusted-proxy CIDR list (settings.tls.trustedProxies, env override VERVAIN_TRUSTED_PROXIES) parsed into ipnet::IpNet with precedence env > config > default empty, mirroring settings.tls.mode. When the immediate TCP peer is inside a trusted range, the server resolves the real client IP from X-Forwarded-For using the rightmost-untrusted rule; otherwise the forwarded header is ignored and the socket peer is used, so a client outside the trusted set cannot spoof its source IP. An empty list preserves today's socket-peer behavior byte-for-byte.
The resolver lives in vervain-config (resolve_client_ip, pure and unit-tested) and is exposed to the web layer as a ClientAddr axum extractor that reads ConnectInfo plus the header and consults AppState.trusted_proxies. All browser/HTTP-listener client-IP sites switch to it: grouprelay, enroll-bundle, CrowdSec bouncer, login rate limit, MCP tunnel, and the control channel. The agent mTLS listener handler keeps the raw peer because agents dial it directly and are never behind the HTTP proxy.
The setting is operator-only system config: it is not in RUNTIME_EDITABLE_SETTINGS_KEYS, so it is neither readable nor writable through the settings overlay web UI / REST API, matching settings.tls.mode. Documented alongside the existing TLS-offload docs in the README.
#VS-83