Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions dappnode/backport-dashboard-auth.py
Original file line number Diff line number Diff line change
@@ -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")


Expand Down
16 changes: 11 additions & 5 deletions setup-wizard/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ <h2>Configure Ollama</h2>
<div class="field">
<label>Ollama Server URL</label>
<div class="hint">If auto-detect doesn't find it, enter the URL manually.</div>
<input type="text" id="ollama-url" placeholder="http://ollama.dappnode:11434">
<input type="text" id="ollama-url" placeholder="http://ollama-cpu.dappnode:11434">
</div>
<div class="field">
<label>Model</label>
Expand Down Expand Up @@ -1182,6 +1182,12 @@ <h2>Configure ${p.name}</h2>
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;
Expand All @@ -1192,8 +1198,8 @@ <h2>Configure ${p.name}</h2>
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") {
Expand Down Expand Up @@ -1257,10 +1263,10 @@ <h2>Configure ${p.name}</h2>
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();
Expand Down
4 changes: 4 additions & 0 deletions setup-wizard/server.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down