Skip to content

Instantly share code, notes, and snippets.

@JamesHarker
Last active August 29, 2015 14:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save JamesHarker/213fc5d98b3fa51bcf5a to your computer and use it in GitHub Desktop.
Check a Dentally Webhook Signature
# request_signature - the signature from the X-Dentally-Signature header
# request_body - the JSON body of the webhook request
# secret - the secret for the webhook
require "openssl"
digest = OpenSSL::Digest.new("sha256")
calculated_signature = OpenSSL::HMAC.hexdigest(digest, secret, request_body)
if calculated_signature == request_signature
# Signature matches, everything is good
else
# Ignore the webhook as the signature is invalid
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment