From 6fa67120efe8677a66d3ac0862d703ff4764e9d3 Mon Sep 17 00:00:00 2001 From: wangzhiqiang <40115555+zhiqw@users.noreply.github.com> Date: Wed, 28 Jul 2021 19:45:34 +0800 Subject: [PATCH 1/2] feat: codeup --- spug_api/apps/apis/deploy.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spug_api/apps/apis/deploy.py b/spug_api/apps/apis/deploy.py index d6116ce..86ed372 100644 --- a/spug_api/apps/apis/deploy.py +++ b/spug_api/apps/apis/deploy.py @@ -37,7 +37,9 @@ 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') From c81a28ec67a927a219ef0c0103416f502990401f Mon Sep 17 00:00:00 2001 From: wangzhiqiang <40115555+zhiqw@users.noreply.github.com> Date: Wed, 28 Jul 2021 19:58:16 +0800 Subject: [PATCH 2/2] feat: github --- spug_api/apps/apis/deploy.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spug_api/apps/apis/deploy.py b/spug_api/apps/apis/deploy.py index 86ed372..006839d 100644 --- a/spug_api/apps/apis/deploy.py +++ b/spug_api/apps/apis/deploy.py @@ -45,6 +45,9 @@ def _is_valid_token(request): 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