Skip to content

Fix webhook receive path to validate WebhookToken only#159

Merged
canghai908 merged 1 commit into
3.0from
fix/webhook-token-validation
May 18, 2026
Merged

Fix webhook receive path to validate WebhookToken only#159
canghai908 merged 1 commit into
3.0from
fix/webhook-token-validation

Conversation

@canghai908

Copy link
Copy Markdown
Owner

Summary

  • make /v1/receive validate instance.WebhookToken instead of instance.Token
  • enforce the webhook auth boundary so inbound callbacks no longer accept the Zabbix API token
  • add handler coverage for strict webhook token validation

Why

Webhook callbacks use a dedicated WebhookToken generated during webhook installation. The previous receive path compared inbound X-Token values against the Zabbix API token, which could reject valid webhook callbacks and coupled two independent authentication paths.

Verification

  • go test ./internal/handler -run 'TestReceiveWebhookTokenValidation|TestGetCurrentVersion|TestSystemVersion_Structure'

Webhook callbacks are authenticated by a tenant-scoped WebhookToken
that is generated during webhook installation. The previous receive
path compared inbound X-Token headers against the Zabbix API token,
which breaks alert ingestion and blurs two separate auth boundaries.

This narrows /v1/receive to accept only WebhookToken values and adds
handler coverage for the strict validation behavior.

Constraint: Webhook authentication must remain independent from Zabbix API credentials
Rejected: Fallback to instance.Token when WebhookToken is missing | preserves the buggy token coupling and weakens the auth boundary
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep inbound webhook auth isolated from outbound Zabbix API auth; do not reuse instance.Token on the receive path
Tested: go test ./internal/handler -run 'TestReceiveWebhookTokenValidation|TestGetCurrentVersion|TestSystemVersion_Structure'
Not-tested: Full repository test suite and lint pipeline
@canghai908 canghai908 merged commit be800ca into 3.0 May 18, 2026
2 checks passed
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