|
@@ -3,19 +3,32 @@
|
|
|
Website for Craftbroec RR stuff
|
|
|
"""
|
|
|
|
|
|
+import hashlib
|
|
|
+import hmac
|
|
|
+
|
|
|
from subprocess import call
|
|
|
-from flask import jsonify
|
|
|
+from flask import jsonify, abort, request
|
|
|
from app import app
|
|
|
|
|
|
|
|
|
+secret = "JdFILOA1O7x6WTcsphlszmeQqU5ngoKZ"
|
|
|
+
|
|
|
+
|
|
|
@app.route('/')
|
|
|
def index():
|
|
|
"""Show index page"""
|
|
|
return jsonify(True)
|
|
|
|
|
|
+
|
|
|
@app.route('/deploy', methods=['POST'])
|
|
|
def deploy():
|
|
|
"""Run deploy script"""
|
|
|
+ digest = hmac.new(secret, request.data, hashlib.sha1).hexdigest()
|
|
|
+ signature = request.headers['X-Hub-Signature'].split('=', 1)
|
|
|
+ if (len(signature) < 2 or signature[0] != 'sha1'
|
|
|
+ or not hmac.compare_digest(signature[1], digest)):
|
|
|
+ abort(400, 'Invalid signature')
|
|
|
+
|
|
|
call(["git", "pull"])
|
|
|
call(["touch", "flask.wsgi"])
|
|
|
return jsonify(True)
|