webhook

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllowPrivateIPs bool

AllowPrivateIPs controls whether webhook URLs may resolve to reserved/private IP addresses. When true, the SSRF protection is disabled. This is useful for self-hosted deployments where webhooks target services on the local network.

Deprecated: use ConfigurePrivateDestinationAllowlist to allow only the destinations that the deployment needs.

Functions

func ConfigurePrivateDestinationAllowlist added in v0.31.0

func ConfigurePrivateDestinationAllowlist(entries []string) error

ConfigurePrivateDestinationAllowlist replaces the deployment's webhook allowlist. Each entry must be an exact hostname, an IP address, or a CIDR. Hostnames are matched case-insensitively, IP addresses are treated as single-address CIDRs, and CIDRs are masked to their network address.

The new policy is published only after every entry is valid, so a failed configuration leaves the previous policy intact. Passing an empty slice clears the allowlist.

func GenerateSigningSecret added in v0.30.0

func GenerateSigningSecret() (string, error)

GenerateSigningSecret returns a new Standard Webhooks signing secret in the "whsec_<base64>" form, backed by 32 cryptographically-random bytes — comfortably within the spec's 24–64 byte range.

func Post

func Post(requestPayload *Request) error

Post delivers the request synchronously and returns the receiver's verdict.

func PostAsync

func PostAsync(requestPayload *Request)

PostAsync enqueues the request for bounded asynchronous delivery and does not wait for the response.

func ValidateSigningSecret added in v0.30.0

func ValidateSigningSecret(secret string) error

ValidateSigningSecret checks that secret is either empty (allowed) or contains only printable ASCII characters (0x20–0x7E), excluding all control characters such as \r and \n, which would corrupt the webhook signature headers. When the secret uses the Standard Webhooks "whsec_<base64>" serialization, the base64 body must decode cleanly so signing cannot silently fall back to the wrong key.

func ValidateURL

func ValidateURL(rawURL string) error

ValidateURL checks that rawURL:

  1. Parses as a valid absolute URL.
  2. Uses the http or https scheme.
  3. Does not resolve to a reserved/private IP address.

It returns a gRPC InvalidArgument status error so callers can return it directly.

Types

type Request added in v0.31.0

type Request struct {
	// URL is the destination endpoint.
	URL string
	// Label identifies the delivery in logs, for example an activity type.
	Label string
	// SigningSecret enables Standard Webhooks HMAC-SHA256 signing when non-empty.
	SigningSecret string
	// Payload is the value encoded as the JSON request body.
	Payload any
}

Request is one webhook delivery: Payload is JSON-encoded and posted to URL, signed with SigningSecret when one is set.

Jump to

Keyboard shortcuts

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