Return 403 instead of 401 on missing/insufficient credentials

Closes #2297
This commit is contained in:
Gina Häußge committed 2018-01-22 16:06:36 +01:00
1 parent b5aae0b8fa
commit b1f9e070a4
4 files changed
+25 -16

No files matched your search

+8 -5
View File
@@ -240,6 +240,9 @@ def _logout(user):
octoprint.server.userManager.logout_user(user)
#~~ Test utils
@api.route("/util/test", methods=["POST"])
@restricted_access
@admin_permission.require(403)
@@ -395,25 +398,25 @@ def utilTestPath():
port = int(data["port"])
except:
return make_response("{!r} is not a valid value for port (must be int)".format(data["port"]), 400)
timeout = 3.05
if "timeout" in data:
try:
timeout = float(data["timeout"])
except:
return make_response("{!r} is not a valid value for timeout (must be int or float)".format(data["timeout"]), 400)
protocol = data.get("protocol", "tcp")
if protocol not in ("tcp", "udp"):
return make_response("{!r} is not a valid value for protocol, must be tcp or udp".format(protocol), 400)
from octoprint.util import server_reachable
reachable = server_reachable(host, port, timeout=timeout, proto=protocol)
result = dict(host=host,
port=port,
protocol=protocol,
result=reachable)
return jsonify(**result)