feat(phase-3): workstream 5 — Webhooks & Event Streaming

- DB migrations 016/017: webhook_subscriptions and webhook_deliveries tables
- WebhookService: CRUD for subscriptions, Vault-backed secret storage, delivery history
- WebhookDeliveryWorker: Bull queue, HMAC-SHA256 signatures, exponential backoff,
  SSRF protection (RFC 1918 + loopback + link-local rejection), dead-letter handling
- EventPublisher: publishes 10 event types (agent/credential/token lifecycle);
  optional Kafka adapter activated via KAFKA_BROKERS env var
- AgentService, CredentialService, OAuth2Service: wired to EventPublisher
- WebhookController + routes: 6 endpoints with webhooks:read / webhooks:write scope guards
- KafkaAdapter: optional Kafka producer (kafkajs), no-op when KAFKA_BROKERS unset
- OAuthScope extended: webhooks:read, webhooks:write
- AuditAction extended: webhook.created, webhook.updated, webhook.deleted
- Metrics: agentidp_webhook_dead_letters_total counter added to registry
- 523 unit tests passing; TypeScript strict throughout, zero `any`

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
SentryAgent.ai Developer
2026-03-31 00:07:41 +00:00
parent 03b5de300c
commit 272b69f18d
20 changed files with 1994 additions and 25 deletions

View File

@@ -24,6 +24,12 @@
"GET:/api/v1/federation/partners": ["admin:orgs"],
"GET:/api/v1/federation/partners/:id": ["admin:orgs"],
"PATCH:/api/v1/federation/partners/:id": ["admin:orgs"],
"DELETE:/api/v1/federation/partners/:id": ["admin:orgs"]
"DELETE:/api/v1/federation/partners/:id": ["admin:orgs"],
"POST:/api/v1/webhooks": ["webhooks:write"],
"GET:/api/v1/webhooks": ["webhooks:read"],
"GET:/api/v1/webhooks/:id": ["webhooks:read"],
"PATCH:/api/v1/webhooks/:id": ["webhooks:write"],
"DELETE:/api/v1/webhooks/:id": ["webhooks:write"],
"GET:/api/v1/webhooks/:id/deliveries": ["webhooks:read"]
}
}