Documentation
¶
Overview ¶
Package webhooksig verifies inbound provider push webhooks.
Index ¶
Constants ¶
const ( SignatureHeader = "X-Hub-Signature-256" TokenHeader = "X-Gitlab-Token" )
SignatureHeader is GitHub's HMAC header; TokenHeader is GitLab's bare-secret one.
const MaxBodyBytes int64 = 1 << 20
MaxBodyBytes caps an inbound webhook body. These endpoints are unauthenticated until the signature is checked, and the signature cannot be checked without first reading the body, so the read itself has to be bounded. GitHub caps its own payloads at 25 MB; a push event carries at most 20 commits and runs well under this.
Variables ¶
This section is empty.
Functions ¶
func Verify ¶
Verify reports whether signature authenticates body under secret, accepting either GitHub's X-Hub-Signature-256 HMAC-SHA256 scheme or GitLab's X-Gitlab-Token bare secret.
An empty secret never verifies. Without that guard an unconfigured webhook is open to anyone: the HMAC of any body under an empty key is computable, so the attacker signs their own payload and it checks out.
Types ¶
This section is empty.