Documentation
¶
Overview ¶
Package trustedproxy carries the per-request "arrived through an explicitly configured reverse proxy" signal from router.TrustedRealIP to downstream consumers that must not trust client-supplied forwarding headers on their own (cookie Secure flags, exported base URLs).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForwardedHost ¶
ForwardedHost returns a validated X-Forwarded-Host value only when the request arrived through a trusted proxy. Direct clients cannot steer it.
func ForwardedProto ¶
ForwardedProto returns the X-Forwarded-Proto value only when the request arrived through a trusted proxy. Direct clients can send any value they like, so their header is ignored.
func FromRequest ¶
FromRequest reports whether the request's direct peer matched TRUSTED_PROXY_CIDRS. It is false for direct clients, including direct TLS clients.
func IsHTTPS ¶
IsHTTPS reports whether the browser-facing request used HTTPS: direct TLS always counts, and X-Forwarded-Proto: https is honored only behind a trusted proxy. Otherwise a direct client could spoof the header and either force Secure cookies over plain HTTP or (with a spoofed http value) weaken them.
func ValidateHost ¶
ValidateHost normalizes a Host-style header value and rejects anything that is not a bare host[:port]: userinfo, paths, queries, fragments, whitespace, commas (forwarded lists) and empty values all return "". The result is safe to concatenate into "scheme://host".
Types ¶
This section is empty.