Created
April 19, 2018 23:29
-
-
Save dugjason/618d261e235b1762465e0fb7d7486b81 to your computer and use it in GitHub Desktop.
Simple Sinatra server that will accept webhook payloads from Front, and verify their authenticity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'openssl' | |
require 'Base64' | |
SECRET_KEY = "your-secret-key" | |
post '/payload' do | |
payload = request.body.read | |
if Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), SECRET_KEY, payload)).strip() == request.env['HTTP_X_FRONT_SIGNATURE'] | |
puts "Everything is safe - run my code!" | |
else | |
puts "Danger!" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment