Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeSignature(t time.Time, payload []byte, secret string) []byte
- func ValidatePayload(payload []byte, header string, secret string) error
- func ValidatePayloadIgnoringTolerance(payload []byte, header string, secret string) error
- func ValidatePayloadWithTolerance(payload []byte, header string, secret string, tolerance time.Duration) error
Constants ¶
const ( // DefaultTolerance indicates that signatures older than this will be rejected. DefaultTolerance time.Duration = 300 * time.Second )
Variables ¶
var ( ErrInvalidHeader = errors.New("webhook has invalid Gocxl-Signature header") ErrNoValidSignature = errors.New("webhook had no valid signature") ErrNotSigned = errors.New("webhook has no Gocxl-Signature header") ErrTooOld = errors.New("timestamp wasn't within tolerance") )
This block represents the list of errors that could be raised when using the webhook package.
Functions ¶
func ComputeSignature ¶
ComputeSignature computes a webhook signature using GoCancel's v1 signing method.
func ValidatePayload ¶
ValidatePayload validates the payload against the Gocxl-Signature header using the specified signing secret. Returns an error if the body or Gocxl-Signature header provided are unreadable, if the signature doesn't match, or if the timestamp for the signature is older than DefaultTolerance.
func ValidatePayloadIgnoringTolerance ¶
ValidatePayloadIgnoringTolerance validates the payload against the Gocxl-Signature header header using the specified signing secret. Returns an error if the body or Gocxl-Signature header provided are unreadable or if the signature doesn't match. Does not check the signature's timestamp.
func ValidatePayloadWithTolerance ¶
func ValidatePayloadWithTolerance(payload []byte, header string, secret string, tolerance time.Duration) error
ValidatePayloadWithTolerance validates the payload against the Gocxl-Signature header using the specified signing secret and tolerance window. Returns an error if the body or Gocxl-Signature header provided are unreadable, if the signature doesn't match, or if the timestamp for the signature is older than the specified tolerance.
Types ¶
This section is empty.