📅  最后修改于: 2022-03-11 15:04:48.585000             🧑  作者: Mango
WEBHOOK_SECRET = 'webhook secret key';
post '/payload' do
request.body.rewind
body = request.body.read
signature = request.env['HTTP_X_TAWK_SIGNATURE']
unless verifySignature(body, signature))
// verification failed
end
// verification success
end
def verifySignature(body, signature)
digest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), WEBHOOK_SECRET, body)
return digest == signature
end