Skip to content

Instantly share code, notes, and snippets.

@jswright61
Created September 1, 2019 17:26
Show Gist options
  • Save jswright61/9493fde9a55eb82296e4732cfc34bf48 to your computer and use it in GitHub Desktop.
Save jswright61/9493fde9a55eb82296e4732cfc34bf48 to your computer and use it in GitHub Desktop.
Validate Github Webhook Signature
require "openssl"
module ValidateWebhook
def validate(payload, shared_secret, signature)
# in case "sha1=" is not stripped off the beginning of signature before calling
signature = signature.sub("sha1=", "")
signature == OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), shared_secret, payload)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment