diff options
author | Oliver Poignant <oliver@poignant.se> | 2016-12-09 20:36:38 +0100 |
---|---|---|
committer | Oliver Poignant <oliver@poignant.se> | 2016-12-09 20:36:38 +0100 |
commit | c98d5b22de7bed03c6345775539a405e61e58477 (patch) | |
tree | 4fff1fdca0626bad24d894192369028d1af9d44d /gitautodeploy/parsers/gitlab.py | |
parent | 9e4aa3618ad9f5494847fb95b0958f2f1b43ccb5 (diff) | |
download | Git-Auto-Deploy-c98d5b22de7bed03c6345775539a405e61e58477.zip Git-Auto-Deploy-c98d5b22de7bed03c6345775539a405e61e58477.tar.gz Git-Auto-Deploy-c98d5b22de7bed03c6345775539a405e61e58477.tar.bz2 |
Verify secret token in GitLab requests
Diffstat (limited to 'gitautodeploy/parsers/gitlab.py')
-rw-r--r-- | gitautodeploy/parsers/gitlab.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gitautodeploy/parsers/gitlab.py b/gitautodeploy/parsers/gitlab.py index 86c05fa..68a1982 100644 --- a/gitautodeploy/parsers/gitlab.py +++ b/gitautodeploy/parsers/gitlab.py @@ -39,6 +39,22 @@ class GitLabRequestParser(WebhookRequestParser): return repo_configs, ref or "master", action, repo_urls + def validate_request(self, request_headers, repo_configs): + import logging + + logger = logging.getLogger() + + for repo_config in repo_configs: + + # Validate secret token if present + if 'secret-token' in repo_config and 'x-gitlab-token' in request_headers: + + if repo_config['secret-token'] != request_headers['x-gitlab-token']: + logger.info("Request token does not match the 'secret-token' configured for repository %s." % repo_config['url']) + return False + + return True + class GitLabCIRequestParser(WebhookRequestParser): |