File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import (
1515 client "github.com/gogits/go-gogs-client"
1616 "crypto/hmac"
1717 "crypto/sha256"
18+ "encoding/hex"
1819)
1920
2021// Webhook instance contains all methods needed to process events
@@ -109,10 +110,14 @@ func (hook Webhook) ParsePayload(w http.ResponseWriter, r *http.Request) {
109110 mac := hmac .New (sha256 .New , []byte (hook .secret ))
110111 mac .Write (payload )
111112
112- expectedMAC := mac .Sum (nil )
113+ expectedMAC := hex . EncodeToString ( mac .Sum (nil ) )
113114
114- if ! hmac .Equal ([]byte (signature ), expectedMAC ) {
115+ if ! hmac .Equal ([]byte (signature ), [] byte ( expectedMAC ) ) {
115116 webhooks .DefaultLog .Error ("HMAC verification failed" )
117+ webhooks .DefaultLog .Debug ("LocalHMAC:" + expectedMAC )
118+ webhooks .DefaultLog .Debug ("RemoteHMAC:" + signature )
119+ webhooks .DefaultLog .Debug ("Secret:" + hook .secret )
120+ webhooks .DefaultLog .Debug (string (payload ))
116121 http .Error (w , "403 Forbidden - HMAC verification failed" , http .StatusForbidden )
117122 return
118123 }
You can’t perform that action at this time.
0 commit comments