Support passwordless Pi-hole authentication and UI settings
All checks were successful
Test and publish Homegate / publish (push) Successful in 12m49s
Test and publish Homegate / checks (push) Successful in 29s

This commit is contained in:
2026-10-14 18:12:10 +03:00
parent a83d897b70
commit b305cc1ba8
13 changed files with 130 additions and 33 deletions

View File

@@ -457,10 +457,18 @@ class NPM(API):
class PiHole(API):
def login(self, password):
self.session.headers.pop("X-FTL-SID", None)
self.session.headers.pop("X-FTL-CSRF", None)
self.session.cookies.clear()
session = self.call("POST", "/auth", json={"password": password})["session"]
require(session.get("valid") and session.get("sid"), "Pi-hole authentication failed")
self.session.headers["X-FTL-SID"] = session["sid"]
self.session.headers["X-FTL-CSRF"] = session["csrf"]
# Pi-hole with authentication disabled returns valid=true, sid=null,
# validity=-1 and no CSRF token. It needs neither auth headers nor logout.
no_password = "sid" in session and session["sid"] is None and session.get("validity") == -1
require(session.get("valid") is True and (session.get("sid") or no_password),
"Pi-hole authentication failed")
if session.get("sid"):
self.session.headers["X-FTL-SID"] = session["sid"]
self.session.headers["X-FTL-CSRF"] = session["csrf"]
def records(self):
dns = self.call("GET", "/config/dns")["config"]["dns"]