Created
July 9, 2024 19:29
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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