feat: add system config import, refactor install script and nginx auth
- lib/system_import: new module to import system configs into JSON at daemon startup - daemon/server.py: call import_all() during startup for config reconciliation - daemon/handlers/nginx.py: simplify add_domain auth handling, remove duplicate code - scripts/install.sh: replace inline Python setup with curl-based daemon API calls; apply IP forwarding at runtime - hoover: bump internal asset versions to v=8 - pages: bump asset versions to v=9
This commit is contained in:
@@ -396,34 +396,19 @@ def add_domain(_request: Any, body: dict[str, Any] | None) -> dict[str, Any]:
|
||||
if cert is not None:
|
||||
entry["cert"] = cert
|
||||
|
||||
# Handle auth credentials for management domain
|
||||
# Handle auth credentials
|
||||
auth_user = body.get("auth_user", "").strip()
|
||||
auth_pass = body.get("auth_pass", "")
|
||||
if auth_user and auth_pass:
|
||||
_write_htpasswd(auth_user, auth_pass)
|
||||
auth_dict = {"user": auth_user, "htpasswd": str(HTPASSWD_FILE)}
|
||||
paths_entry = entry.get("paths", {})
|
||||
for _ppath, pcfg in paths_entry.items():
|
||||
if pcfg.get("is_management"):
|
||||
pcfg["auth"] = auth_dict
|
||||
break
|
||||
entry["auth"] = auth_dict
|
||||
|
||||
# Handle auth credentials for management paths
|
||||
auth_user = body.get("auth_user", "").strip()
|
||||
auth_pass = body.get("auth_pass", "").strip()
|
||||
if auth_user and auth_pass:
|
||||
_write_htpasswd(auth_user, auth_pass)
|
||||
auth_entry = {
|
||||
auth = {
|
||||
"user": auth_user,
|
||||
"htpasswd": str(HTPASSWD_FILE),
|
||||
}
|
||||
# Store auth on root path if it exists
|
||||
root_path = entry.get("paths", {}).get("/")
|
||||
if root_path:
|
||||
root_path["auth"] = auth_entry
|
||||
# Also store at domain level for template
|
||||
entry["auth"] = auth_entry
|
||||
root_path["auth"] = auth
|
||||
entry["auth"] = auth
|
||||
|
||||
cfg["domains"][domain] = entry
|
||||
_save_config(cfg)
|
||||
|
||||
Reference in New Issue
Block a user