File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ def initialize(
31
31
logger . info 'Parsed JSON payload.'
32
32
33
33
is_ping = ping_checker . ping? ( push )
34
- is_valid_sig = signature_verifier . verify_signature ( payload_body , request )
34
+ is_valid_sig = signature_verifier . verify_signature ( payload_body , request . env [ 'HTTP_X_HUB_SIGNATURE' ] )
35
35
36
36
if is_ping
37
37
logger . info 'Received ping.'
Original file line number Diff line number Diff line change 1
1
require 'sinatra'
2
2
3
3
class SignatureVerifier
4
- def verify_signature ( payload_body , request )
4
+ def verify_signature ( payload_body , header )
5
+ return false unless header
6
+
5
7
signature = 'sha1=' + OpenSSL ::HMAC . hexdigest (
6
8
OpenSSL ::Digest . new ( 'sha1' ) ,
7
9
ENV [ 'WEBHOOK_SECRET_TOKEN' ] ,
8
10
payload_body
9
11
)
10
- header = request . env [ 'HTTP_X_HUB_SIGNATURE' ]
11
- return false unless header
12
- return false unless Rack ::Utils . secure_compare ( signature , header )
12
+ Rack ::Utils . secure_compare ( signature , header )
13
13
end
14
14
end
You can’t perform that action at this time.
0 commit comments