Skip to content

feat(logging): log allowlisted HTTP headers across request lifecycle#58

Merged
thomasdesr merged 1 commit into
mainfrom
thomas/log-allowlisted-headers
Jun 24, 2026
Merged

feat(logging): log allowlisted HTTP headers across request lifecycle#58
thomasdesr merged 1 commit into
mainfrom
thomas/log-allowlisted-headers

Conversation

@thomasdesr

Copy link
Copy Markdown
Owner

Logs HTTP headers at three points in the proxy flow, restricted to a hardcoded allowlist of headers known to be safe:

  • Inbound (request started) — what the client sent us
  • Upstream request (fetching upstream) — what we forward after injecting Accept and conditional headers
  • Upstream response — what the server sent back

The allowlist (reqlog.safeHeaders) covers headers like Accept, 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 response log 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 Authorization and Set-Cookie are absent.

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.
@thomasdesr thomasdesr marked this pull request as ready for review June 24, 2026 19:03
@thomasdesr thomasdesr merged commit 0f935ca into main Jun 24, 2026
5 checks passed
@thomasdesr thomasdesr deleted the thomas/log-allowlisted-headers branch June 24, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant