diff --git a/dappnode/backport-dashboard-auth.py b/dappnode/backport-dashboard-auth.py index 703e6b7..8af02e4 100644 --- a/dappnode/backport-dashboard-auth.py +++ b/dappnode/backport-dashboard-auth.py @@ -1,33 +1,43 @@ #!/usr/bin/env python3 """Backport the password-provider auto-SSO guard from upstream main.""" +import re from pathlib import Path MIDDLEWARE_PATH = Path( "/opt/hermes/hermes_cli/dashboard_auth/middleware.py" ) -ORIGINAL = """ provider = providers[0] - prefix = prefix_from_request(request) -""" -PATCHED = """ provider = providers[0] - if getattr(provider, "supports_password", False): - return None - prefix = prefix_from_request(request) -""" +GUARD_RE = re.compile( + r'^ if getattr\(provider, "supports_password", False\):\n' + r"^ return None\n", + re.MULTILINE, +) +ORIGINAL_RE = re.compile( + r"(^ provider = providers\[0\]\n)" + r"(^ prefix = prefix_from_request\(request\)\n)", + re.MULTILINE, +) + + +def add_password_guard(match: re.Match[str]) -> str: + return ( + match.group(1) + + ' if getattr(provider, "supports_password", False):\n' + + " return None\n\n" + + match.group(2) + ) def main() -> None: source = MIDDLEWARE_PATH.read_text(encoding="utf-8") - if PATCHED in source: + if GUARD_RE.search(source): print("[dappnode] Dashboard password-provider SSO fix already present") return - if source.count(ORIGINAL) != 1: - raise SystemExit( - "Could not apply dashboard auth backport: upstream middleware changed" - ) - MIDDLEWARE_PATH.write_text( - source.replace(ORIGINAL, PATCHED), encoding="utf-8" - ) + patched, count = ORIGINAL_RE.subn(add_password_guard, source, count=1) + if count != 1: + print("[dappnode] Dashboard auth middleware changed; skipping obsolete backport") + return + MIDDLEWARE_PATH.write_text(patched, encoding="utf-8") print("[dappnode] Applied dashboard password-provider SSO fix") diff --git a/setup-wizard/index.html b/setup-wizard/index.html index 716312d..03ff5c4 100644 --- a/setup-wizard/index.html +++ b/setup-wizard/index.html @@ -1001,7 +1001,7 @@

Configure Ollama

If auto-detect doesn't find it, enter the URL manually.
- +
@@ -1182,6 +1182,12 @@

Configure ${p.name}

return null; } + function toOpenAiBaseUrl(url) { + const raw = (url || "").trim(); + const base = (raw || "http://ollama-cpu.dappnode:11434").replace(/\/+$/, ""); + return base.endsWith("/v1") ? base : base + "/v1"; + } + function buildEnv() { const env = {}; const p = selectedProvider; @@ -1192,8 +1198,8 @@

Configure ${p.name}

env.OPENAI_API_KEY = apiKey; env.LLM_MODEL = getModelValue() || "deepseek/deepseek-v4-pro"; } else if (p.id === "ollama") { - const url = (document.getElementById("ollama-url").value || "").trim() || "http://ollama.dappnode:11434"; - env.OPENAI_BASE_URL = url + "/v1"; + const url = toOpenAiBaseUrl(document.getElementById("ollama-url").value); + env.OPENAI_BASE_URL = url; env.OPENAI_API_KEY = "ollama-local"; env.LLM_MODEL = getModelValue() || "llama3"; } else if (p.id === "custom") { @@ -1257,10 +1263,10 @@

Configure ${p.name}

lines.push(` context_length: ${matched.context_length}`); } } else if (p.id === "ollama") { - const url = (document.getElementById("ollama-url").value || "").trim() || "http://ollama.dappnode:11434"; + const url = toOpenAiBaseUrl(document.getElementById("ollama-url").value); lines.push(` default: "${getModelValue() || "llama3"}"`); lines.push(` provider: "custom"`); - lines.push(` base_url: "${url}/v1"`); + lines.push(` base_url: "${url}"`); } else if (p.id === "custom") { const spec = document.getElementById("custom-spec").value; const baseUrl = (document.getElementById("custom-base-url").value || "").trim(); diff --git a/setup-wizard/server.cjs b/setup-wizard/server.cjs index 33dc944..00ec69f 100644 --- a/setup-wizard/server.cjs +++ b/setup-wizard/server.cjs @@ -18,6 +18,10 @@ const DASHBOARD_PUBLIC_URL = process.env.DAPPNODE_DASHBOARD_URL const DASHBOARD_LOGIN_URL = new URL("login?next=%2F", DASHBOARD_PUBLIC_URL).toString(); const OLLAMA_CANDIDATES = [ + "http://ollama-cpu.dappnode:11434", + "http://ollama-nvidia.dappnode:11434", + "http://ollama-amd.dappnode:11434", + "http://ollama.dappnode:11434", "http://ollama.ollama-nvidia-openwebui.dappnode:11434", "http://ollama.ollama-amd-openwebui.dappnode:11434", "http://ollama.ollama-cpu-openwebui.dappnode:11434",