Skip to content

Instantly share code, notes, and snippets.

@JamesHarker
Last active November 14, 2024 05:29
Show Gist options
  • Save JamesHarker/213fc5d98b3fa51bcf5a to your computer and use it in GitHub Desktop.
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