diff options
Diffstat (limited to 'remote-https-runner/runner.py')
| -rw-r--r-- | remote-https-runner/runner.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/remote-https-runner/runner.py b/remote-https-runner/runner.py index 2fa03b5..02d0958 100644 --- a/remote-https-runner/runner.py +++ b/remote-https-runner/runner.py @@ -27,25 +27,27 @@ config_keys = config.keys() @app.route("/<key>", methods=["POST"]) def key(key): logging.info("User requested route \"{}\"".format(key)) - if not key in config_keys: - logging.warning("Route \"{}\" does not exist!".format(key)) - return Response("", status=404) options = config[key] - auth_header = request.headers.get('Authorization') protocol = request.url.split("://")[0] logging.info("User uses protocol {}".format(protocol)) - #if protocol != "https": + if protocol != "https": + logging.error("Using plain HTTP is strongly discouraged! Please upgrade to HTTPS.") # return Response("HTTP requests not allowed! Use HTTPS!", status=400) + auth_header = request.headers.get('Authorization') auth = options["auth"] if auth != auth_header: logging.warning("User request rejected due to incorrect Authorization header!") return Response("", status=401) + if not key in config_keys: + logging.warning("Route \"{}\" does not exist!".format(key)) + return Response("", status=404) + if request.content_type != "application/json": logging.warning("User request rejected due to incorrect content type (must be application/json)!") - return Response("", status=401) + return Response("", status=400) content = request.json |
