Skip to content

Commit

Permalink
Fix verify webhook (#80)
Browse files Browse the repository at this point in the history
fixes #79
  • Loading branch information
ferhatelmas authored Jun 5, 2020
1 parent b317f1d commit 3b385cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"crypto"
"crypto/hmac"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -158,11 +159,10 @@ func (c *Client) createToken(claims jwt.Claims) (string, error) {
// VerifyWebhook validates if hmac signature is correct for message body
func (c *Client) VerifyWebhook(body, signature []byte) (valid bool) {
mac := hmac.New(crypto.SHA256.New, c.apiSecret)
//nolint: errcheck
mac.Write(body)
_, _ = mac.Write(body)

expectedMAC := mac.Sum(nil)
return hmac.Equal(signature, expectedMAC)
expectedMAC := hex.EncodeToString(mac.Sum(nil))
return bytes.Equal(signature, []byte(expectedMAC))
}

type sendFileResponse struct {
Expand Down

0 comments on commit 3b385cd

Please sign in to comment.