Skip to content

feat(audit): a webhook sink can take its token by reference - #71

Merged
blakebauman merged 1 commit into
mainfrom
feat/audit-bearer-secret-ref
Aug 14, 2026
Merged

blakebauman merged 1 commit into
mainfrom
feat/audit-bearer-secret-ref

Conversation

@blakebauman

Copy link
Copy Markdown
Member

Why

audit.sinks[].headers takes static values, so a receiver that authenticates leaves the operator writing the credential into the config document. That makes the config the one part of a fold deployment that cannot be checked in, logged, or handed to somebody debugging a federation — and the audit trail is the sink most likely to need a credential.

discovery and the decision hook both already solve this with bearerSecretRef. The AuditSink struct's own comment has been pointing at that convention — "the same shape an audit webhook sink takes" — while the audit sink was the one that could not use it.

What

{
  "type": "webhook",
  "url": "https://siem.example.com/ingest",
  "bearerSecretRef": "FOLD_AUDIT_TOKEN"
}

Resolved from the environment at construction, sent as Authorization: Bearer ….

Two refusals rather than guesses:

  • Both bearerSecretRef and an Authorization header is rejected. That is two authors disagreeing, and picking one sends the audit trail with the wrong credential. The check is case-insensitive, because header names are and config files are written by hand.
  • An empty variable at startup fails the sink loudly rather than delivering unauthenticated — the receiver would refuse the batch, fold would retry it, and the trail would look delivered while accumulating in the dead-letter file.

Named on a sink that makes no requests (file, stdout) is also rejected: a credential that looks configured and is silently ignored is worse than one that is missing.

The caller's header map is copied rather than written into, so the credential does not end up in whatever that config is used for next.

Verification

make check green; golangci-lint 0 issues. New tests cover delivery with the token, the empty-variable startup error, the no-mutation property, and each validation refusal. The JSON schema is updated — TestSchemaMatchesStructs caught it, which is the guard working.

🤖 Generated with Claude Code

`headers` takes static values, so a receiver that authenticates leaves the
operator writing the credential into the config document — which makes that
document the one part of a fold deployment that cannot be checked in, logged,
or handed to somebody debugging a federation. The audit trail is the sink most
likely to need a credential, and it was the only one of the three request-
making features without a way to keep it out.

`bearerSecretRef` names an environment variable, exactly as `discovery` and
the decision hook already do. The struct's own comment has been pointing at
this convention — "the same shape an audit webhook sink takes" — while the
audit sink was the one that could not use it.

Two refusals rather than guesses. Setting both `bearerSecretRef` and an
`Authorization` header is two authors disagreeing, and picking one sends the
audit trail with the wrong credential; the check is case-insensitive because
header names are and config files are written by hand. And a variable that is
empty at startup fails the sink loudly rather than delivering unauthenticated:
the receiver would refuse the batch, fold would retry it, and the trail would
look delivered while accumulating in the dead-letter file.

The caller's header map is copied rather than written into, so the credential
does not end up in whatever that config is used for next.
@blakebauman
blakebauman merged commit 35c07f1 into main Aug 14, 2026
8 checks passed
@blakebauman
blakebauman deleted the feat/audit-bearer-secret-ref branch August 14, 2026 19:27
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