Verified Commit cd213901 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

don't throw exception if header not available

parent f74f196b
......@@ -48,14 +48,10 @@ class AutoDeploy(Resource):
try:
headers = flaskRequest.headers
secure_token = getenv('SECURE_TOKEN')
if secure_token:
app.logger.info(secure_token[:3] + "***")
else:
app.logger.info("No secure_token found")
if secure_token and not headers['X-Gitlab-Token']:
if secure_token and not headers.get('X-Gitlab-Token'):
app.logger.info('Request does not have an X-Gitlab-Token in headers')
return '{}', 403
if secure_token and headers['X-Gitlab-Token'].rstrip() is not secure_token.rstrip():
if secure_token and headers.get('X-Gitlab-Token').rstrip() is not secure_token.rstrip():
app.logger.warning('Request does not have a valid X-Gitlab-Token in headers')
return '{}', 403
body = json.loads(flaskRequest.data.decode('utf-8'))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment