Browse Source

Make this usable with our hook, but also with github

Oz N Tiram 9 years ago
parent
commit
d9938cd559
3 changed files with 5 additions and 2 deletions
  1. 3 1
      frank/conf.py
  2. 1 1
      frank/frank.py
  3. 1 0
      hooks/post-update.sh

+ 3 - 1
frank/conf.py

@@ -1,7 +1,9 @@
-
 GITHUB_USER, GITUB_PASSWORD = "user", "secret"
 POST_KEY = '6361675'
 FRANK_DATABASE = 'frank.sqlite3'
+SECRET_KEY_NAME='X-Secret'
+# IF using github, you should change 'X-Secret' to 'X-Hub-Signature'
+
 
 # notes about config
 # the config should be able to set destroy build or not.

+ 1 - 1
frank/frank.py

@@ -246,7 +246,7 @@ def start():
     """
     ans = hmac.new(app.config['POST_KEY'], request.data,
                    hashlib.sha1).hexdigest()
-    secret = request.headers['X-Secret'].split('=')[-1]
+    secret = request.headers[app.config['SECRET_KEY_NAME']].split('=')[-1]
     if ans != secret:
         return abort(500)
     request_as_json = request.get_json()

+ 1 - 0
hooks/post-update.sh

@@ -40,4 +40,5 @@ done
 SECRET=$(echo -n $JSON_TO_SUBMIT | openssl dgst -sha1 -hmac $SECRET_KEY)
 SECRET=`echo $SECRET | cut -d'=' -f2`
 # TODO: Consider submiting to HTTPS!
+# Github uses X-Hub-Signature, we use X-Secret
 curl  -H "Content-Type: application/json" -H "X-Secret:${SECRET}" -X POST http://${SUBMIT_HOST}:${SUBMIT_PORT}/ -d ${JSON_TO_SUBMIT}