install-newt: optional internet access via a Pangolin tunnel, with OIDC sign-in on the dashboard
A plain install is unchanged: LAN-only, dashboard behind the API key. `llmhost install-newt` is the upgrade path. It installs a pinned, sha256-checked newt as a third user service and switches the dashboard to an OIDC authorization-code + PKCE sign-in limited to allowed groups or users. The API still takes the key. Secrets live in 0600 files, never in config.json, a service file or argv. `llmhost remove-newt` undoes it; setup/update keep it; `logs --newt` shows the tunnel (and `logs -f` now follows the service it was asked for). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d07a92e5b5
commit
e814a2359d
11 changed files with 1155 additions and 26 deletions
|
|
@ -6,6 +6,9 @@ Layout (overridable with LLMHOST_HOME / LLMHOST_CONFIG):
|
|||
~/.local/share/llm-host/cuda merged CUDA toolkit built from pip wheels (NVIDIA)
|
||||
~/.config/llm-host/config.json plan + settings
|
||||
~/.config/llm-host/api_key API key (0600)
|
||||
~/.local/share/llm-host/newt newt binary, after `llmhost install-newt`
|
||||
~/.config/llm-host/oidc_secret dashboard sign-in client secret (0600), after install-newt
|
||||
~/.config/llm-host/newt_secret Pangolin site secret (0600), after install-newt
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
|
|
@ -21,6 +24,9 @@ DATA = Path(os.environ.get("LLMHOST_HOME", HOME / ".local/share/llm-host"))
|
|||
CONFIG_DIR = Path(os.environ.get("LLMHOST_CONFIG", HOME / ".config/llm-host"))
|
||||
CONFIG_FILE = CONFIG_DIR / "config.json"
|
||||
KEY_FILE = CONFIG_DIR / "api_key"
|
||||
OIDC_SECRET_FILE = CONFIG_DIR / "oidc_secret"
|
||||
NEWT_SECRET_FILE = CONFIG_DIR / "newt_secret"
|
||||
NEWT_DIR = DATA / "newt"
|
||||
LOG_DIR = (HOME / "Library/Logs/llm-host") if IS_MAC else (DATA / "logs")
|
||||
BIN_DIR = HOME / ".local/bin"
|
||||
SHIM = BIN_DIR / "llmhost"
|
||||
|
|
@ -66,3 +72,23 @@ def api_key(create: bool = False) -> str:
|
|||
with os.fdopen(fd, "w") as f:
|
||||
f.write(key + "\n")
|
||||
return key
|
||||
|
||||
|
||||
|
||||
def read_secret(path, what, fix) -> str:
|
||||
try:
|
||||
return path.read_text().strip()
|
||||
except OSError:
|
||||
raise SystemExit(f"No {what} at {path}; run `{fix}` again.")
|
||||
|
||||
|
||||
def save_secret(path, secret: str) -> None:
|
||||
CONFIG_DIR.mkdir(parents=True, exist_ok=True)
|
||||
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600)
|
||||
with os.fdopen(fd, "w") as f:
|
||||
f.write(secret + "\n")
|
||||
os.chmod(path, 0o600) # O_CREAT's mode doesn't apply to a file that already existed
|
||||
|
||||
|
||||
def oidc_secret() -> str:
|
||||
return read_secret(OIDC_SECRET_FILE, "dashboard sign-in client secret", "llmhost install-newt")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue