-
-
Save KyMidd/8ac94b8a7622e997aaedb8820e14f159 to your computer and use it in GitHub Desktop.
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
| # Validate the signature | |
| def validate_signature(GITHUB_SECRET, event, body): | |
| incoming_signature = re.sub(r'^sha1=', '', event['headers']['X-Hub-Signature']) | |
| incoming_payload = unquote(re.sub(r'^payload=', '', event['body'])) | |
| calculated_signature = calculate_signature(GITHUB_SECRET, incoming_payload.encode('utf-8')) | |
| if incoming_signature != calculated_signature: | |
| print("Unauthorized attempt") | |
| sys.exit() | |
| else: | |
| print("🚀 Confirmed HMAC matches, authorized access, continuing") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment