From 3d791a3e45b3d2db94901f871fbf2804c666954d Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Tue, 18 Dec 2018 22:57:59 +0200 Subject: Small improvements --- remote-https-runner/runner.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'remote-https-runner') 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("/", 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 -- cgit v1.3