Skip to content

fix(source): reject misplaced auth keys in source config and stop guessing HMAC defaults - #492

Draft
leggetter wants to merge 1 commit into
mainfrom
fix/source-config-auth-shape
Draft

leggetter wants to merge 1 commit into
mainfrom
fix/source-config-auth-shape

Conversation

@leggetter

Copy link
Copy Markdown
Collaborator

Auth fields placed at the top level of --config / --source-config were silently dropped by the API, so this exited 0 and created a source with no signature verification:

hookdeck gateway connection upsert vapi-acme-dental \
  --source-name vapi-acme-dental --source-type VAPI \
  --source-config '{"webhook_secret_key":"<secret>","algorithm":"sha256","encoding":"hex","header_key":"x-signature"}' \
  --destination-id <destination_id>

The CLI forwards config JSON unchanged except four legacy keys (webhook_secret, api_key, basic_auth, hmac), and the API validates with stripUnknown: true, so nothing reported the problem.

Changes

  • Misplaced auth keys fail. validateSourceConfigAuthShape rejects webhook_secret_key, algorithm, encoding, header_key, trim_payload, api_key, username and password at the top level of source config, names them, and prints the corrected JSON with secrets as <placeholder>. Applies to source create/upsert/update (--config, --config-file) and connection create/upsert (--source-config, --source-config-file).
  • The shorthand stops guessing. --webhook-secret, --source-webhook-secret and the legacy webhook_secret key send only webhook_secret_key for provider types (e.g. VAPI, STRIPE), so the API applies the type's own defaults (VAPI: x-signature). WEBHOOK, HTTP and an empty type keep x-webhook-signature/sha256/hex, since they have no server-side defaults.
  • Tests in pkg/cmd/source_common_test.go. go build ./..., go test ./... and gofmt pass.

Unfinished (for whoever takes this to completion)

  • No check after create that auth is configured: responses redact auth, so this needs one test against a real API to see what can be detected.
  • Hard error vs warning: a hard error could break scripts that pass flat keys today (those scripts already create unverified sources).
  • Fixed key list: provider-specific auth fields not in the list still pass through; real validation depends on pkg/cmd/sources is dead code: source auth validation never runs #341.
  • No CHANGELOG or REFERENCE.md entry; no acceptance test.

Related: #341 (CLI-side auth validation is inert), #412 (source update config rejected), #466 (success reported while a change is ignored). The API side is in hookdeck/core.

🤖 Generated with Claude Code

Posted by an AI agent with human oversight.

…lts for provider types

Auth fields (webhook_secret_key, header_key, ...) at the top level of source config were dropped by the API, creating an unverified source with exit 0. Fail with the corrected JSON instead. The webhook-secret shorthand now sends only the secret for provider source types so the API applies their own header/algorithm/encoding defaults (e.g. VAPI x-signature); WEBHOOK/HTTP keep x-webhook-signature/sha256/hex.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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