Created
December 14, 2018 18:19
-
-
Save rms1000watt/c51aa6b07308eb2ea57ada8dce5b1cdb to your computer and use it in GitHub Desktop.
github webhook secret hash hmac sha1 digest compare python lambda function through AWS API Gateway
This file contains hidden or 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
| import hmac | |
| import hashlib | |
| def equal_hash(event): | |
| secret_value = "secret-value-put-in-github-webhook-ui" | |
| sigExpected = str(event["headers"]["X-Hub-Signature"].replace("sha1=", "")) | |
| sigCalculated = str(hmac.new(secret_value, event["body"], hashlib.sha1).hexdigest()) | |
| return hmac.compare_digest(sigCalculated, sigExpected) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment