我如何在Ubuntu Webhook commad上设置webhook secret?

时间:2018-11-30 12:33:14

标签: json ubuntu github webhooks

详细信息如下。

apt-get install webhook
vim hooks.json
----------:
[
{
    "id": "plan",
     "execute-command": "/opt/hooks.com/hooks.sh",
     "command-working-directory": "/opt/plan",
     "response-message": "Webhook is rebuilding"
},
----------:


webhook -port 9500 -hooks hooks.json -verbose -hotreload -ip 10.128.22.125

此处钩子URL为https://hooks.com/hooks/plan

这将触发挂钩并在给定目录上执行bash脚本。我正在从GitHub调用此webhook URL来触发推送事件。我想在此Webhook中添加秘密,以确保从挂钩URL调用时的安全性。请帮助我通过此Webhook设置秘密令牌。

谢谢。

1 个答案:

答案 0 :(得分:1)

https://github.com/adnanh/webhook/blob/master/docs/Hook-Rules.md

处找到了解决方案

vim hooks.json ----------: [ { "id": "plan", "execute-command": "/opt/hooks.com/hooks.sh", "command-working-directory": "/opt/plan", "response-message": "Webhook is rebuilding" "trigger-rule": { "and": [ { "match": { "type": "payload-hash-sha1", "secret": "yourSecretToken", "parameter": { "source": "header", "name": "X-Hub-Signature" } } } ] } } ]