Skip to content

Instantly share code, notes, and snippets.

@akhenakh
Created July 9, 2024 19:29
Show Gist options
  • Save akhenakh/ca2bd51995f43c6ffc771643671c3900 to your computer and use it in GitHub Desktop.
Save akhenakh/ca2bd51995f43c6ffc771643671c3900 to your computer and use it in GitHub Desktop.
A github webhook receiver for Benthos. SECRET_KEY=BLAH benthos -c benthos.yaml
http:
enabled: true
address: 0.0.0.0:8095
root_path: /api
debug_endpoints: false
input:
label: webhook_server
http_server:
path: "/webhook/github"
rate_limit: flood_protect
rate_limit_resources:
- label: flood_protect
local:
count: 100
interval: 1s
pipeline:
processors:
- bloblang: |
root = this
root.signature_valid = if meta("X-Hub-Signature-256") == content().string().hash("hmac_sha256","${SECRET_KEY}").encode("hex") {
true
} else {
false
}
output:
switch:
cases:
- check: 'this.signature_valid == true'
output:
stdout: {}
- output:
reject: "Invalid signature"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment