diff --git a/configuration/observability.mdx b/configuration/observability.mdx index 56ee053..d90035d 100644 --- a/configuration/observability.mdx +++ b/configuration/observability.mdx @@ -161,3 +161,44 @@ X-Forwarded-Proto: https You also have the ability to provide a signing secret for requests to your webhook. If you specify a signing secret, you will receive a request with the `X-Flipt-Webhook-Signature` header populated. The value in the header is the request body HMAC sha256 signed with the signing secret you specified. On the webhook server, you can validate the signature by using the same signing secret. It is _strongly recommended_ that you do this to prevent requests to your webhook server that are from invalid origins. + +#### Webhook Templates + +Starting from [v1.28.0](https://github.com/flipt-io/flipt/releases/tag/v1.28.0), you can specify a template for the body of an Audit Event Webhook request. + +A sample configuration can look something like this: + +```yaml +audit: + sinks: + webhook: + enabled: true + templates: + - url: https://example.com + headers: + Content-Type: application/json + Authorization: Bearer this-is-a-seret-token + body: | + { + "type": {{ .Type }}, + "action": {{ .Action }} + } +``` + +This configuration tells Flipt to send a `POST` request when events need to be emitted to the URL `https://example.com` with the HTTP headers, `Content-Type` and `Authorization`, and the body which is a [Go template](https://pkg.go.dev/text/template) that will be executed when an event comes in. The event structure looks like this: + +```go +type Event struct { + Version string `json:"version"` + Type Type `json:"type"` + Action Action `json:"action"` + + Metadata Metadata `json:"metadata"` + + Payload interface{} `json:"payload"` + + Timestamp string `json:"timestamp"` +} +``` + +Any of the values that are [exposed](https://github.com/flipt-io/flipt/blob/v1.28.0/internal/server/audit/audit.go#L51-L61) by Flipt are fair game for inclusion in your HTTP body template. diff --git a/configuration/overview.mdx b/configuration/overview.mdx index 6463d05..2434895 100644 --- a/configuration/overview.mdx +++ b/configuration/overview.mdx @@ -246,6 +246,7 @@ These properties are as follows: | audit.sinks.webhook.url | URL to send audit events to | | v1.27.0 | | audit.sinks.webhook.signing_secret | Signing secret to use for verification of origin on webhook server | | v1.27.0 | | audit.sinks.webhook.max_backoff_duration | Max exponential backoff duration for sending webhook upon failure | 15s | v1.27.0 | +| audit.sinks.webhook.templates[] | List of webhook templates for Flipt to send audit events to | | v1.28.0 | ### Tracing