Created
December 30, 2014 14:55
-
-
Save nim65s/06cfeae09f7703e35aa7 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
#!/usr/bin/env python | |
from __future__ import print_function | |
from hashlib import sha1 | |
from hmac import new | |
from os import environ, system | |
from sys import stdin | |
KEY_FILE = '/etc/github.key' | |
EXEC_CMD = 'sudo /usr/local/bin/github_push.sh' | |
print("Content-type: text") | |
print("") | |
payload = stdin.read() | |
key = open(KEY_FILE).read().strip() | |
digest = 'sha1=' + new(key, payload, sha1).hexdigest() | |
if digest == environ['HTTP_X_HUB_SIGNATURE']: | |
system(EXEC_CMD) | |
print("ok") | |
else: | |
print('wrong password') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment