Skip to content

Instantly share code, notes, and snippets.

@dugjason
Created April 19, 2018 23:29
Show Gist options
  • Save dugjason/618d261e235b1762465e0fb7d7486b81 to your computer and use it in GitHub Desktop.
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
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