Did you know ... Search Documentation:
webhook.pl -- Authorize GitHub webhook requests
PublicShow source

Handlers such as /blog/pull and /examples/pull run `git pull`, rebuild indexes and purge the CDN. They may only be triggered by

  • GitHub, using a webhook with a shared secret. The request must carry a valid X-Hub-Signature-256 header: an HMAC-SHA256 of the request body using the secret. The secret is the setting webhook:secret, set in data/private/plweb.conf as
    setting(webhook:secret, 'the secret').

    and in the GitHub webhook configuration (Settings/Webhooks/Secret).

  • A logged in admin, from a page on this site.

Anything else is refused with 403 (Forbidden).

Source webhook_authorized(+Request) is det
Succeed if Request may trigger a webhook action. Otherwise throw an HTTP 403 reply. For signed requests the body is read.
Source read_body(+Request, -Body:string) is semidet[private]
Read the raw request body as a string of bytes (octets).
Source same_string(+A, +B) is semidet[private]
Compare in time that only depends on the length, such that the signature cannot be guessed from response times.