Skip to content

Commit e3f6a8a

Browse files
Func: Re-write body before passing to handler
1 parent 9c969e2 commit e3f6a8a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

signature/signature.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,18 @@ func (v *Validator) CalculateSignature(ts, qp string, b []byte) ([]byte, error)
9494
// ValidSignature takes the timestamp, query params and body from the request,
9595
// calculates the expected signature and compares it to the one sent by MessageBird.
9696
func (v *Validator) ValidSignature(ts, rqp string, b []byte, rs string) bool {
97-
uqp, _ := url.Parse("?" + rqp)
98-
es, _ := v.CalculateSignature(ts, uqp.Query().Encode(), b)
99-
drs, _ := base64.StdEncoding.DecodeString(rs)
97+
uqp, err := url.Parse("?" + rqp)
98+
if err != nil {
99+
return false
100+
}
101+
es, err := v.CalculateSignature(ts, uqp.Query().Encode(), b)
102+
if err != nil {
103+
return false
104+
}
105+
drs, err := base64.StdEncoding.DecodeString(rs)
106+
if err != nil {
107+
return false
108+
}
100109
return hmac.Equal(drs, es)
101110
}
102111

0 commit comments

Comments
 (0)