From 030714ae80bef133bda6b0762a5048989b0a3ba1 Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 3 Dec 2018 18:46:24 +0800 Subject: [PATCH] Fix server authentication. --- gns3server/web/route.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gns3server/web/route.py b/gns3server/web/route.py index 72943e61..9e7d0eee 100644 --- a/gns3server/web/route.py +++ b/gns3server/web/route.py @@ -104,20 +104,21 @@ class Route(object): :returns: Response if you need to auth the user otherwise None """ + if not server_config.getboolean("auth", False): - return + return None user = server_config.get("user", "").strip() password = server_config.get("password", "").strip() - if len(user) == 0: + if not user: return if "AUTHORIZATION" in request.headers: if request.headers["AUTHORIZATION"] == aiohttp.helpers.BasicAuth(user, password, "utf-8").encode(): - return + return None - log.error("Invalid auth. Username should %s", user) + log.error("Invalid authentication. Username should be {}".format(user)) response = Response(request=request, route=route) response.set_status(401) @@ -169,7 +170,7 @@ class Route(object): # Authenticate response = cls.authenticate(request, route, server_config) - if response: + if response is not None: return response try: