def refresh(slug=None): data = os.urandom(250) hmac = utils.compute_hmac(data) url = config.BASE_URL + "/refresh" if slug: url = url + "/" + slug r = requests.post(url, headers={"X-Hub-Signature": "sha1=" + hmac}, data=data) r.raise_for_status() print(r.text)
def authentification(): # Only SHA1 is supported header_signature = flask.request.headers.get('X-Hub-Signature') if header_signature is None: LOG.warning("Webhook without signature") flask.abort(403) try: sha_name, signature = header_signature.split('=') except ValueError: sha_name = None if sha_name != 'sha1': LOG.warning("Webhook signature malformed") flask.abort(403) mac = utils.compute_hmac(flask.request.data) if not hmac.compare_digest(mac, str(signature)): LOG.warning("Webhook signature invalid") flask.abort(403)