mirror of
https://github.com/adnanh/webhook.git
synced 2025-06-30 08:18:31 +00:00
fixed payload-hash-sha1 for github header
This commit is contained in:
parent
40d01e4d5a
commit
0b269e4870
1 changed files with 4 additions and 0 deletions
|
@ -12,6 +12,10 @@ import (
|
||||||
|
|
||||||
// CheckPayloadSignature calculates and verifies SHA1 signature of the given payload
|
// CheckPayloadSignature calculates and verifies SHA1 signature of the given payload
|
||||||
func CheckPayloadSignature(payload []byte, secret string, signature string) (string, bool) {
|
func CheckPayloadSignature(payload []byte, secret string, signature string) (string, bool) {
|
||||||
|
if strings.HasPrefix(signature, "sha1=") {
|
||||||
|
signature = signature[5:]
|
||||||
|
}
|
||||||
|
|
||||||
mac := hmac.New(sha1.New, []byte(secret))
|
mac := hmac.New(sha1.New, []byte(secret))
|
||||||
mac.Write(payload)
|
mac.Write(payload)
|
||||||
expectedMAC := hex.EncodeToString(mac.Sum(nil))
|
expectedMAC := hex.EncodeToString(mac.Sum(nil))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue