mirror of
https://github.com/adnanh/webhook.git
synced 2025-06-01 02:02:28 +00:00
Add soft signature failure support
Add a new trigger-signature-soft-failures option to allow soft signature failures in Or rules. Fixes #234
This commit is contained in:
parent
3e18a060ae
commit
6d2f26d952
7 changed files with 554 additions and 6 deletions
|
@ -95,6 +95,16 @@ func (e *SignatureError) Error() string {
|
|||
return fmt.Sprintf("invalid payload signature %s%s", e.Signature, empty)
|
||||
}
|
||||
|
||||
// IsSignatureError returns whether err is of type SignatureError.
|
||||
func IsSignatureError(err error) bool {
|
||||
switch err.(type) {
|
||||
case *SignatureError:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// ArgumentError describes an invalid argument passed to Hook.
|
||||
type ArgumentError struct {
|
||||
Argument Argument
|
||||
|
@ -563,6 +573,7 @@ type Hook struct {
|
|||
JSONStringParameters []Argument `json:"parse-parameters-as-json,omitempty"`
|
||||
TriggerRule *Rules `json:"trigger-rule,omitempty"`
|
||||
TriggerRuleMismatchHttpResponseCode int `json:"trigger-rule-mismatch-http-response-code,omitempty"`
|
||||
TriggerSignatureSoftFailures bool `json:"trigger-signature-soft-failures,omitempty"`
|
||||
IncomingPayloadContentType string `json:"incoming-payload-content-type,omitempty"`
|
||||
SuccessHttpResponseCode int `json:"success-http-response-code,omitempty"`
|
||||
HTTPMethods []string `json:"http-methods"`
|
||||
|
@ -845,7 +856,9 @@ func (r OrRule) Evaluate(req *Request) (bool, error) {
|
|||
rv, err := v.Evaluate(req)
|
||||
if err != nil {
|
||||
if !IsParameterNodeError(err) {
|
||||
return false, err
|
||||
if !req.AllowSignatureErrors || (req.AllowSignatureErrors && !IsSignatureError(err)) {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue