fix(events): verify webhook signatures before parsing (#2021)
A source now declares how its deliveries prove themselves: token (the default, unchanged), hmac (HMAC-SHA256 over the raw body, per-source header and prefix, secret sealed at rest and write-only) or none. The events module verifies before the connector parses, answers 401 and logs the refusal. The digest comparison is ported from internal/webhookguard/hmac.go and the header-borne signature from internal/infrastructure/captureintake/receiver.go; the old copies stay until their service goes. The seal package moves to internal/platform/seal so events can seal the secret.
This commit is contained in:
15 files changed
+415
-65
No files matched your search
+30
-3
@@ -948,14 +948,13 @@ components:
|
||||
source:
|
||||
type: string
|
||||
token:
|
||||
description: Shown once; only its hash is stored
|
||||
description: Shown once, for a token source; only its hash is stored
|
||||
type: string
|
||||
url:
|
||||
description: Where the sender posts its events
|
||||
type: string
|
||||
required:
|
||||
- source
|
||||
- token
|
||||
- url
|
||||
type: object
|
||||
EventsSourceView:
|
||||
@@ -963,6 +962,12 @@ components:
|
||||
properties:
|
||||
connector:
|
||||
type: string
|
||||
hmac_header:
|
||||
type: string
|
||||
hmac_prefix:
|
||||
type: string
|
||||
hmac_secret_set:
|
||||
type: boolean
|
||||
key_fields:
|
||||
items:
|
||||
type: string
|
||||
@@ -973,11 +978,15 @@ components:
|
||||
type: string
|
||||
token_set:
|
||||
type: boolean
|
||||
verification:
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
- connector
|
||||
- key_fields
|
||||
- token_set
|
||||
- verification
|
||||
- hmac_secret_set
|
||||
type: object
|
||||
EventsTriggerRun:
|
||||
additionalProperties: false
|
||||
@@ -2074,6 +2083,24 @@ components:
|
||||
connector:
|
||||
description: The connector that parses this source's events
|
||||
type: string
|
||||
hmac_header:
|
||||
description: The header that carries the signature, for hmac
|
||||
type: string
|
||||
hmac_prefix:
|
||||
description: Text before the hex digest in that header, such as sha256=, for hmac
|
||||
examples:
|
||||
- sha256=
|
||||
type: string
|
||||
hmac_secret:
|
||||
description: "The shared signing secret, for hmac. Write-only: it is sealed and never returned"
|
||||
type: string
|
||||
verification:
|
||||
description: "How a delivery proves itself: a bearer token, an HMAC-SHA256 signature of the body, or nothing"
|
||||
enum:
|
||||
- token
|
||||
- hmac
|
||||
- none
|
||||
type: string
|
||||
required:
|
||||
- connector
|
||||
type: object
|
||||
@@ -5354,7 +5381,7 @@ paths:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ErrorModel"
|
||||
description: Error
|
||||
summary: Add a source or rotate its token
|
||||
summary: Add a source, or change how it verifies deliveries and rotate its token
|
||||
tags:
|
||||
- Events
|
||||
/api/sources/{name}/key-fields:
|
||||
|
||||
Reference in new issue
Block a user