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
93
README.md
93
README.md
|
|
@ -50,9 +50,11 @@ PYTHONPATH=. python3 -P -m llmhost plan --simulate apple:64 # a 64 GB Mac
|
|||
| `llmhost switch <model>` | serve a different model (downloads it first if needed) |
|
||||
| `llmhost download <model>` | download ahead of time |
|
||||
| `llmhost watch` | download and loading progress, until the model is ready |
|
||||
| `llmhost logs -f` | follow the model server log |
|
||||
| `llmhost logs -f` | follow the model server log (`--web` for the dashboard's, `--newt` for the tunnel's) |
|
||||
| `llmhost start` / `stop` / `restart` | control the model server (stop frees the GPU) |
|
||||
| `llmhost key` | print the API key |
|
||||
| `llmhost install-newt` | optional: reach this server from the internet through a Pangolin tunnel, with OIDC sign-in on the dashboard (see [Reaching it from the internet](#reaching-it-from-the-internet)) |
|
||||
| `llmhost remove-newt` | undo `install-newt`: back to LAN-only, dashboard back to the API key |
|
||||
| `llmhost opencode-setup` | install opencode here if needed and connect it to this server |
|
||||
| `llmhost opencode-config` | print what to add to opencode on another machine |
|
||||
| `llmhost opencode-remove` | take llm-host back out of this machine's opencode config (`--host` for a retired remote server, `--all` for every one) |
|
||||
|
|
@ -67,6 +69,86 @@ prompt tokens with the seconds and rate of the prefill, then generated tokens wi
|
|||
the generation. A request that didn't stream has no first-token mark, so its prompt seconds read `—` and its
|
||||
whole duration counts as generation.
|
||||
|
||||
## Reaching it from the internet
|
||||
|
||||
A plain install is LAN-only, and the dashboard asks for the API key. To let people use it from
|
||||
anywhere, `llmhost install-newt` adds two things on top:
|
||||
|
||||
- **A tunnel.** [newt](https://github.com/fosrl/newt) dials out to your [Pangolin](https://github.com/fosrl/pangolin)
|
||||
server, which serves HTTPS on your domain. Nothing on this machine is opened to the internet, and no port is forwarded.
|
||||
newt runs as a third user service, in userspace (no root). It's a pinned release, checked against its sha256 before it's installed.
|
||||
- **OIDC sign-in on the dashboard, replacing the API key there.** Whoever holds the key can also stop or
|
||||
switch the model from the dashboard, which is too much to hand out with the key. The API itself is
|
||||
unchanged and still takes the key.
|
||||
|
||||
You need a Pangolin server with a Newt site (Pangolin: *Sites → Add Site → Newt*, which gives an endpoint, ID and
|
||||
secret) and an OIDC client registered with your identity provider:
|
||||
|
||||
- a confidential client using `client_secret_basic`
|
||||
- the authorization-code flow with PKCE (S256)
|
||||
- scopes `openid profile email groups`
|
||||
- the redirect URI `https://<dashboard host>/auth/callback`
|
||||
|
||||
Then:
|
||||
|
||||
```bash
|
||||
llmhost install-newt \
|
||||
--endpoint https://pangolin.example.com --newt-id <site id> \
|
||||
--public-url https://llm-dash.example.com \
|
||||
--issuer https://auth.example.com --client-id llm-host \
|
||||
--allow-group llm-admins # and/or --allow-user <username>; repeatable
|
||||
```
|
||||
|
||||
It asks for anything left out. The two secrets are always prompted for, or read from `$LLMHOST_NEWT_SECRET` and
|
||||
`$LLMHOST_OIDC_SECRET`, and never taken as flags, so they stay out of shell history. They're stored in
|
||||
`~/.config/llm-host/` with mode 600 and handed to the services at start; they're never written into a service
|
||||
file or `config.json`. Running it again changes only what you give it.
|
||||
|
||||
It ends by printing the two Pangolin HTTP resources to create, both pointing at this machine's LAN address (not
|
||||
`localhost`, which llm-host treats as local), and **with Pangolin's own SSO off**:
|
||||
|
||||
| resource | target | who checks |
|
||||
|---|---|---|
|
||||
| dashboard, at the `--public-url` host | `<LAN IP>:<web port>` | llm-host, through your OIDC provider |
|
||||
| API, at a host of your choice | `<LAN IP>:<API port>` | llm-host, with the API key |
|
||||
|
||||
Clients then use `https://<API host>/v1` with the key from `llmhost key`.
|
||||
|
||||
For Authelia, the client looks like this:
|
||||
|
||||
```yaml
|
||||
identity_providers:
|
||||
oidc:
|
||||
clients:
|
||||
- client_id: llm-host
|
||||
client_name: llm-host dashboard
|
||||
client_secret: '$pbkdf2-sha512$...' # authelia crypto hash generate pbkdf2 --random
|
||||
public: false
|
||||
authorization_policy: two_factor
|
||||
require_pkce: true
|
||||
pkce_challenge_method: S256
|
||||
redirect_uris: ['https://llm-dash.example.com/auth/callback']
|
||||
scopes: [openid, profile, email, groups]
|
||||
response_types: [code]
|
||||
grant_types: [authorization_code]
|
||||
token_endpoint_auth_method: client_secret_basic
|
||||
```
|
||||
|
||||
How the dashboard's sign-in behaves:
|
||||
|
||||
- **Only listed people get in.** A person must be in an allowed group or have an allowed username
|
||||
(`preferred_username`, falling back to email). Groups come from userinfo.
|
||||
- **Sessions are HttpOnly, Secure, `SameSite=Lax` cookies.** They last 12 hours and are held in memory, so
|
||||
restarting the dashboard signs everyone out. State-changing requests must come from the dashboard's own origin.
|
||||
- **The ID token is checked.** Its issuer, audience, expiry and nonce must match. It arrives directly from the
|
||||
token endpoint over TLS, which OIDC allows in place of verifying its signature.
|
||||
- **Other addresses redirect to the public URL.** A visit to any other name for the machine
|
||||
(`http://<host>.local:11340`) is sent there, because that's the only host the session cookie exists on.
|
||||
|
||||
`llmhost status` shows the tunnel and sign-in settings. `setup` and `update` keep them, and `update` moves newt to
|
||||
a newly pinned release. `llmhost remove-newt` undoes it all: it removes the service, the binary and both secrets,
|
||||
and switches the dashboard back to the key.
|
||||
|
||||
## Connecting opencode
|
||||
|
||||
**On the server itself**, setup handles it: if opencode isn't installed it offers to install it (official
|
||||
|
|
@ -204,6 +286,8 @@ python3 tests/test_opencode.py # or run one directly
|
|||
| `tests/test_opencode.py` | provider naming and ownership, removal, the credential cache |
|
||||
| `tests/test_proxy.py` | model names, dropping client reasoning settings, upstream key, streamed-run counting, against a fake server |
|
||||
| `tests/test_dashboard.py` | KV parsing, per-run summaries, log collapsing |
|
||||
| `tests/test_dashboard_auth.py` | API-key mode, and OIDC sign-in against a fake provider: PKCE, state/nonce/aud/iss/exp checks, allow list, origin check, sign-out |
|
||||
| `tests/test_newt.py` | `install-newt`/`remove-newt` against fake services: pinned checksum, secrets kept out of config, output and argv, re-runs, undo |
|
||||
| `tests/test_reasoning.py` | effort options matching the real chat templates; the setting surviving an update |
|
||||
|
||||
## Continuing on an NVIDIA box
|
||||
|
|
@ -248,6 +332,9 @@ suites are hermetic and don't need a GPU), so run that first.
|
|||
| `~/.local/share/llm-host/` | this repo (`src/`), backend venvs, the assembled CUDA toolkit |
|
||||
| `~/.config/llm-host/config.json` | the plan: backend, fitting models, active model, ports |
|
||||
| `~/.config/llm-host/api_key` | API key (mode 600) |
|
||||
| `~/.config/llm-host/oidc_secret` | dashboard sign-in client secret (mode 600), after `install-newt` |
|
||||
| `~/.config/llm-host/newt_secret` | Pangolin site secret (mode 600), after `install-newt` |
|
||||
| `~/.local/share/llm-host/newt/` | the newt binary, after `install-newt` |
|
||||
| `~/.cache/huggingface/hub/` | downloaded models |
|
||||
| Linux: `~/.config/systemd/user/llm-host-{model,web}.service` | services (`journalctl --user -u llm-host-model`) |
|
||||
| macOS: `~/Library/LaunchAgents/dev.llm-host.{model,web}.plist` | services; logs in `~/Library/Logs/llm-host/` |
|
||||
|
|
@ -262,4 +349,6 @@ On macOS the services are launchd agents, so they run while you're logged in.
|
|||
`reasoning_effort` (top-level or in `chat_template_kwargs`) is dropped and the dashboard's
|
||||
setting applied instead.
|
||||
- AMD (ROCm), Intel and CPU-only machines aren't supported yet.
|
||||
- The API and dashboard use plain HTTP and are meant for a trusted LAN. Don't expose them to the internet.
|
||||
- The API and dashboard use plain HTTP and are meant for a trusted LAN. Don't forward their ports to the internet;
|
||||
use [`llmhost install-newt`](#reaching-it-from-the-internet), which puts HTTPS in front and OIDC sign-in on the dashboard.
|
||||
- Everyone using the API shares one key, with no per-person revocation or rate limits.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue