Documentation
¶
Overview ¶
Package forwardauth implements the forward-auth adapter used by Traefik's ForwardAuth middleware.
For every client request the proxy sends a subrequest to Path. The original method, URI and host arrive in X-Forwarded-* headers, the client's other headers are copied, and the body is included when the proxy is configured to forward it. A 2xx answer lets the request through; the proxy returns any other answer to the client as is.
The proxy must overwrite client-supplied X-Forwarded-* headers. In Traefik that is trustForwardHeader: false. With true, Traefik keeps a client's own X-Forwarded-Uri, and the engine would inspect a URI chosen by the attacker while the real one is forwarded.
The proxy must also forward the body (Traefik: forwardBody: true with a maxBodySize above the engine's limit). Otherwise bodies reach the application uninspected.
Index ¶
Constants ¶
const Path = "/v1/forward-auth"
Path is where the proxy sends its subrequests.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// MaxBodyBytes is how much of a forwarded body is inspected. Zero
// disables body inspection.
MaxBodyBytes int64
// ClientIP resolves the client address from X-Forwarded-For. The proxy
// is the direct peer, so its address must be trusted. Nil trusts no
// proxies.
ClientIP *clientip.Resolver
// Logger receives one security event per denied or logged request.
// Nil uses slog.Default().
Logger *slog.Logger
}
Config configures a Handler.