Support passwordless Pi-hole authentication and UI settings
This commit is contained in:
@@ -136,9 +136,13 @@ class Panel:
|
||||
if self.config_data()[1] != revision:
|
||||
raise UIError("Настройки уже изменились. Обновите страницу.", 409)
|
||||
values = h.read_json(self.connections_file, {})
|
||||
allowed = {"npm_url", "npm_identity", "npm_password", "pihole_url", "pihole_password", "ssh_public_url", "api_ca_pem"}
|
||||
allowed = {"npm_url", "npm_identity", "npm_password", "pihole_url", "pihole_password", "ssh_public_url", "api_ca_pem", "clear_pihole_password"}
|
||||
h.require(not set(connections) - allowed, "Unknown connection field")
|
||||
clear_pihole_password = connections.get("clear_pihole_password", False)
|
||||
h.require(isinstance(clear_pihole_password, bool), "clear_pihole_password must be boolean")
|
||||
for key, value in connections.items():
|
||||
if key == "clear_pihole_password":
|
||||
continue
|
||||
h.require(isinstance(value, str), f"{key} must be text")
|
||||
if key.endswith("_password") and not value and values.get(key):
|
||||
continue
|
||||
@@ -151,6 +155,8 @@ class Panel:
|
||||
client = h.API(values.get(key, ""), key.removesuffix("_url").upper())
|
||||
client.close()
|
||||
values.setdefault("pihole_password", "")
|
||||
if clear_pihole_password:
|
||||
values["pihole_password"] = ""
|
||||
if values.get("ssh_public_url"):
|
||||
url = urlsplit(values["ssh_public_url"])
|
||||
h.require(url.scheme in ("http", "https") and url.hostname and not url.username and not url.fragment,
|
||||
|
||||
Reference in New Issue
Block a user