Documentation
¶
Index ¶
- Variables
- func ConfigurePrivateDestinationAllowlist(entries []string) error
- func GenerateSigningSecret() (string, error)
- func Post(requestPayload *WebhookRequestPayload) error
- func PostAsync(requestPayload *WebhookRequestPayload)
- func ValidateSigningSecret(secret string) error
- func ValidateURL(rawURL string) error
- type WebhookRequestPayload
Constants ¶
This section is empty.
Variables ¶
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
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
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 *WebhookRequestPayload) error
Post posts the message to webhook endpoint.
func PostAsync ¶
func PostAsync(requestPayload *WebhookRequestPayload)
PostAsync posts the message to webhook endpoint asynchronously. It enqueues the request for bounded asynchronous dispatch and does not wait for the response.
func ValidateSigningSecret ¶ added in v0.30.0
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 ¶
ValidateURL checks that rawURL:
- Parses as a valid absolute URL.
- Uses the http or https scheme.
- Does not resolve to a reserved/private IP address.
It returns a gRPC InvalidArgument status error so callers can return it directly.
Types ¶
type WebhookRequestPayload ¶
type WebhookRequestPayload struct {
// The target URL for the webhook request.
URL string `json:"url"`
// The type of activity that triggered this webhook.
ActivityType string `json:"activityType"`
// The resource name of the creator. Format: users/{user}
Creator string `json:"creator"`
// The memo that triggered this webhook (if applicable).
Memo *v1pb.Memo `json:"memo"`
// Optional signing secret for HMAC-SHA256 signature. Not serialized to JSON.
SigningSecret string `json:"-"`
}