Documentation
¶
Overview ¶
Package httpadapter holds request handling shared by the adapters that receive requests over net/http: the reverse proxy and forward-auth.
Index ¶
- func IsEvent(v pipeline.Verdict) bool
- func IsToken(s string) bool
- func LogEvent(ctx context.Context, logger *slog.Logger, rec *events.Recorder, ...)
- func NewRequestID() string
- func PeerAddr(remoteAddr string) netip.Addr
- func RequestID(id string) string
- func SnapshotHeaders(r *http.Request) http.Header
- func URIPath(rawURI string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsEvent ¶
IsEvent reports whether a verdict is logged as a security event: blocks and detections, and every request that went uninspected unexpectedly (timeout, error, overload). Client cancellations and requests uninspected by configuration (a skipped route, no policy for the route, inspection suspended) are not events: they are counted in the metrics, and logging each would flood the logs. Neither are the requests an engine denies before it has a policy bundle (bootstrap deny): the engine logs that once.
func LogEvent ¶
func LogEvent(ctx context.Context, logger *slog.Logger, rec *events.Recorder, req *request.Request, path string, v pipeline.Verdict)
LogEvent writes one security event for req, and records it for the operator when rec is set.
func NewRequestID ¶
func NewRequestID() string
NewRequestID returns a random 16-hex-digit request ID.
func RequestID ¶
RequestID returns id if it is a safe correlation ID (at most 128 of [A-Za-z0-9._:-]), and "" otherwise so that one is generated. The value is client-controlled and ends up in logs and events.
func SnapshotHeaders ¶
SnapshotHeaders returns a private copy of r's headers for inspection, with Transfer-Encoding and Content-Length restored.
The copy matters because an evaluation that times out keeps running after the handler has returned, and must not read the live request. Copying costs about 0.3µs, well under 0.1% of an evaluation.
net/http moves Transfer-Encoding out of the header map, and Content-Length can be absent (HTTP/2) even when the length is known. Without them, rules see a POST with neither header and raise a false positive.
Types ¶
This section is empty.