correctly check for project ident in request

This commit is contained in:
2019-10-06 12:24:52 +02:00
parent 918782ff3e
commit 47ad4e0fa8

View File

@@ -21,11 +21,18 @@ def rootPage():
data = flask.request.json
print(json.dumps(flask.request.json, indent=4, sort_keys=True))
# check for project in request
project = None
try:
project = data["project"][PROJECT_IDENTIFIER]
except KeyError:
return ("Rejected: missing project/{} json path".format(PROJECT_IDENTIFIER), 400)
# check for project in config #
if data["project"][PROJECT_IDENTIFIER] not in config:
if not project or project not in config:
return ("Rejected: project not identified in config", 400)
token, scriptName = data["project"][PROJECT_IDENTIFIER]
token, scriptName = config[project]
# check authentification #
if TOKEN_HEADER not in flask.request.headers: