mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 22:11:14 +02:00
Improvement to validate HTTP authentication config. Ref #1662
This commit is contained in:
1 parent
5a3f8b9a9b
commit
1b845225b2
2 files changed
+12
-5
No files matched your search
@@ -111,14 +111,14 @@ class Route(object):
|
||||
user = server_config.get("user", "").strip()
|
||||
password = server_config.get("password", "").strip()
|
||||
|
||||
if not user:
|
||||
return
|
||||
|
||||
if "AUTHORIZATION" in request.headers:
|
||||
if user and "AUTHORIZATION" in request.headers:
|
||||
if request.headers["AUTHORIZATION"] == aiohttp.helpers.BasicAuth(user, password, "utf-8").encode():
|
||||
return None
|
||||
|
||||
log.error("Invalid authentication. Username should be {}".format(user))
|
||||
if not user:
|
||||
log.error("HTTP authentication is enabled but no username is configured")
|
||||
else:
|
||||
log.error("Invalid authentication for username '{}'".format(user))
|
||||
|
||||
response = Response(request=request, route=route)
|
||||
response.set_status(401)
|
||||
|
||||
Reference in new issue
Block a user