Merge pull request #360 from zhiqw/add-webhook

webhook valid_token  Codeup & Github
pull/369/head
vapao 2021-07-29 14:11:06 +08:00 committed by GitHub
commit 07e6d00ce3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -37,12 +37,17 @@ def auto_deploy(request, deploy_id, kind):
def _is_valid_token(request):
api_key = AppSetting.get_default('api_key')
token = request.headers.get('X-Gitlab-Token') or request.headers.get('X-Gitee-Token')
token = request.headers.get('X-Gitlab-Token')
token = token or request.headers.get('X-Gitee-Token')
token = token or request.headers.get('X-Codeup-Token')
if token:
return token == api_key
token = request.headers.get('X-Gogs-Signature')
if token:
return token == hmac.new(api_key.encode(), request.body, hashlib.sha256).hexdigest()
token = request.headers.get('X-Hub-Signature', '').split('=')[-1]
if token:
return token == hmac.new(api_key.encode(), request.body, hashlib.sha1).hexdigest()
return False