Documentation
¶
Overview ¶
Signatures of the events services post to webhooks: the schemes services sign with, a table the verifier reads in its order, alpha's generic one among them (X-Webhook-Signature-V2 over a timestamp and the body, X-Webhook-Signature over the body alone); the secret of a webhook and the one before it while a rotation overlaps; and the lines a person writing a sender follows
Index ¶
Constants ¶
const ( // Whatever scheme the event comes signed in, as alpha checks: the first of the table whose headers it carries decides Auto = "auto" Standard = "standard" Icebath = "icebath" Linear = "linear" GitHub = "github" GitLab = "gitlab" Generic = "generic" GenericV1 = "generic-v1" )
Names a webhook picks its scheme by
const ( SignatureV2Header = "X-Webhook-Signature-V2" TimestampHeader = "X-Webhook-Timestamp" SignatureV1Header = "X-Webhook-Signature" IcebathHeader = "X-Icebath-Signature-256" )
Headers of the generic scheme and of icebath's own events
const Window = 5 * time.Minute
How far a signed timestamp may be from the listener's clock before the event counts as sent again by someone who saw it: alpha's 300 seconds, either way
Variables ¶
var Schemes = []Scheme{ {Name: Standard, Title: "Svix and Standard Webhooks", About: "webhook-id, webhook-timestamp and webhook-signature, or svix- ones", /* contains filtered or unexported fields */}, {Name: Icebath, Title: "icebath's own", About: "X-Icebath-Signature-256 as icebath's shell hooks and tests sign", Written: true, Replayable: true, // contains filtered or unexported fields }, {Name: Linear, Title: "Linear", About: "linear-signature, the hex HMAC of the body", /* contains filtered or unexported fields */}, {Name: GitHub, Title: "GitHub", About: "X-Hub-Signature-256, sha256= and the hex HMAC of the body", /* contains filtered or unexported fields */}, {Name: GitLab, Title: "GitLab", About: "X-Gitlab-Token, the secret itself", Replayable: true, /* contains filtered or unexported fields */}, {Name: Generic, Title: "Generic, with a timestamp", About: "X-Webhook-Signature-V2 over X-Webhook-Timestamp and the body", Written: true, /* contains filtered or unexported fields */}, {Name: GenericV1, Title: "Generic, the body alone", About: "X-Webhook-Signature over the body, open to being sent again", Replayable: true, Written: true, // contains filtered or unexported fields }, }
The schemes, in the order the verifier asks whether an event carries each, as alpha does: Svix and Standard Webhooks, icebath's own, Linear, GitHub, GitLab, then the generic one with a timestamp, then the generic one of the body alone
Functions ¶
Types ¶
type Refusal ¶
Why an event's signature was refused, a sentence a sender reads, and the scheme it was checked in, empty when none
type Request ¶
One event posted to a webhook: its headers and its body as they came, and the time it is judged at
type Scheme ¶
type Scheme struct {
// Word a webhook names it by, and what a person calls it and what signs that way
Name, Title, About string
// It signs the body alone, with no time, so an event seen once can be sent again and still match
Replayable bool
// The scheme is icebath's own, for senders a person writes: a webhook of it is shown the lines such a sender follows
Written bool
// contains filtered or unexported fields
}
One way services sign what they post
type Secrets ¶
Secrets a webhook takes: its own, and the one it had before a rotation, taken too until the overlap ends
type Verdict ¶
What a signature that matched proved: the scheme it came in, that it was signed with the secret before a rotation, and that the scheme signs the body alone, so whoever saw the event could send it again
func Verify ¶
Whether the event's signature matches one of the secrets in the scheme the webhook takes, Auto taking the first of the table whose headers the event carries and no other, as alpha does: a timestamped generic signature with no timestamp is refused, never checked as one of the body alone. A scheme the webhook names takes events signed that way alone. The secret before a rotation is taken until the overlap ends. Refused with a Refusal saying why