Sijo M Cyril
Sijo M Cyril

Reputation: 780

How can I setup webhook secret on Ubuntu webhook commad?

Details are given below.

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

Here hook URL is https://hooks.com/hooks/plan

This will trigger the hook and execute bash script on given directory. I am calling this webhook URL from GitHub to trigger on push events. I would like to add secrets to this webhook to ensure security when calling from hook URL. Please help me to setup secrets token with this webhook.

Thanks in advance.

Upvotes: 1

Views: 1865

Answers (1)

Sijo M Cyril
Sijo M Cyril

Reputation: 780

Found a solution here https://github.com/adnanh/webhook/blob/master/docs/Hook-Rules.md

vim hooks.json

and put in the following content:

[
{
    "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"
            }
          }
        }
      ]
    }
   }
]

Upvotes: 1

Related Questions