Last active
November 14, 2024 05:29
-
-
Save JamesHarker/213fc5d98b3fa51bcf5a to your computer and use it in GitHub Desktop.
Check a Dentally Webhook Signature
This file contains 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
# 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