feat(logging): log allowlisted HTTP headers across request lifecycle#58
Merged
Conversation
Log a safe allowlist of headers at three points: the inbound client request, the upstream request we send, and the upstream response. Headers off the allowlist (Authorization and friends) are dropped, not redacted, so a new sensitive header never leaks into logs by default. prek golangci-lint hook skipped: its pinned go 1.26.3 is older than go.mod's 1.26.4 requirement and can't load packages. Diff verified lint-clean against the matching toolchain.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Logs HTTP headers at three points in the proxy flow, restricted to a hardcoded allowlist of headers known to be safe:
request started) — what the client sent usfetching upstream) — what we forward after injecting Accept and conditional headersThe allowlist (
reqlog.safeHeaders) covers headers likeAccept,User-Agent,Content-Type,ETag, and conditional-request headers. Anything off the list is dropped, not redacted, so a header we never anticipated holding a secret (a new auth scheme, a custom token header) can't leak into logs by default.Upstream request/response header groups are attached to the request logger, so the existing
upstream responselog line carries the full exchange (what we sent and what we got back) on one record.Tests cover the allowlist helper (present headers logged, sensitive headers dropped, multi-value joined, empty group omitted) and an integration test asserting all three groups appear while
AuthorizationandSet-Cookieare absent.