Skip to content

Instantly share code, notes, and snippets.

@nim65s
Created December 30, 2014 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nim65s/06cfeae09f7703e35aa7 to your computer and use it in GitHub Desktop.
Save nim65s/06cfeae09f7703e35aa7 to your computer and use it in GitHub Desktop.
#!/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