webhooksig

package
v1.10.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package webhooksig verifies inbound provider push webhooks.

Index

Constants

View Source
const (
	SignatureHeader = "X-Hub-Signature-256"
	TokenHeader     = "X-Gitlab-Token"
)

SignatureHeader is GitHub's HMAC header; TokenHeader is GitLab's bare-secret one.

View Source
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

func Verify(secret, signature string, body []byte) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL