mirror of
https://github.com/debpalash/VoiceStudio.git
synced 2026-12-04 09:28:22 +00:00
Drop the admin session's store id from the whoami response: it is the hash revocation is keyed on and no client needs it. Document and test that a remote caller with no credential gets 401 from the credential gate when an API key or share PIN is configured. Regenerate the mobile OpenAPI contract and route inventory, and drop the BOM from the changelog fragment.
535 lines
29 KiB
Markdown
535 lines
29 KiB
Markdown
# Authenticating the local API
|
|
|
|
For an application backend consuming a pinned, private VoiceStudio deployment,
|
|
start with the [production private API pattern](production-private-api.md).
|
|
|
|
VoiceStudio's backend is **loopback-only and unauthenticated by default** — a
|
|
script running on the same machine as `http://localhost:3900` needs no key, no
|
|
PIN, no header. Everything on this page only matters once you reach the backend
|
|
from **another device** (a phone on your LAN, a laptop over Tailscale, a client
|
|
behind a reverse proxy).
|
|
|
|
There are two independent gates, both **inert until you turn them on**, plus one
|
|
env var that exempts trusted callers:
|
|
|
|
| Gate | Turn on with | Guards | Applies to |
|
|
|---|---|---|---|
|
|
| **Share PIN** | the in-app Network share toggle | casual LAN-share guests, one session | non-loopback **HTTP** |
|
|
| **API key** | `OMNIVOICE_API_KEY` env var on the backend | direct clients and first-party session bootstrap | non-loopback **HTTP + WebSocket** |
|
|
| **Trusted networks** | `OMNIVOICE_TRUSTED_NETWORKS` env var | *exempts* the two gates above | non-loopback **consumption** routes only |
|
|
|
|
The route authorization census (`scripts/dump_route_auth.py`) records effective
|
|
FastAPI dependencies, including nested dependencies. Its policy test requires
|
|
every mutating HTTP route and every WebSocket to carry a recognized gate or an
|
|
explicit, documented exception. Only the read-only `GET /` frontend fallback is
|
|
excluded; mutations and WebSockets at `/` remain visible. Exceptions record the
|
|
current policy, including known gaps; they do not add authorization themselves.
|
|
All four WebSocket paths additionally await the shared inline `require_ws_access`
|
|
guard before accepting a connection. The census lists this in-body authorization
|
|
explicitly because it cannot infer it from FastAPI dependencies. The HTTP-only
|
|
share PIN does not authorize a socket; the WebSocket policy is detailed below.
|
|
|
|
Loopback traffic (`127.0.0.1`, `::1`, `localhost`) is **never** gated — local
|
|
tools keep working unchanged whichever gate is set.
|
|
|
|
> VoiceStudio separates **consumption** (TTS, dictation, voices) from
|
|
> **administration** (`/system/*`, `/api/settings/*` — RCE-class). The PIN and
|
|
> trusted networks are *consumption* credentials; the **admin surface is only
|
|
> ever reached from loopback or with the API key**. Host-path capabilities stay
|
|
> desktop-only even with a key (see [Admin routes](#admin-routes-and-server-mode)).
|
|
|
|
> Both gates can be active at once. The PIN and the API key are independent; when
|
|
> both are set, each is checked on the paths it covers. Session exchange validates
|
|
> the master key before the PIN gate so the UI can bootstrap safely; ordinary HTTP
|
|
> requests still require the PIN afterward, and the UI prompts for it next.
|
|
|
|
---
|
|
|
|
## Share PIN
|
|
|
|
The PIN is the lightweight, in-app path: flip on **Network** sharing (footer
|
|
**Local** pill → **Network**, or **Settings → Sharing & Remote Access**) and the
|
|
app generates a fresh **6-digit PIN** for that session. It is regenerated every
|
|
time you enable sharing and is **never written to disk**. See
|
|
[docs/sharing.md](sharing.md) for the UI walkthrough.
|
|
|
|
While a PIN is set, every **non-loopback HTTP request** to an API route must
|
|
present it. Supply it any one of three ways:
|
|
|
|
| Where | How |
|
|
|---|---|
|
|
| Header | `X-OmniVoice-Pin: <pin>` |
|
|
| Query param | `?pin=<pin>` |
|
|
| Cookie | `ov_pin=<pin>` — the backend sets this automatically after the first valid PIN, so browser sessions only prove it once. It is set `HttpOnly; SameSite=Strict` (plus `Secure` on a TLS hop), so scripts in the page cannot read it |
|
|
|
|
```bash
|
|
# From another device on the LAN — with the PIN
|
|
curl http://<host>:3900/v1/audio/voices \
|
|
-H "X-OmniVoice-Pin: 123456"
|
|
```
|
|
|
|
A missing or wrong PIN returns:
|
|
|
|
```
|
|
HTTP/1.1 401 Unauthorized
|
|
{"detail": "PIN required"}
|
|
```
|
|
|
|
Notes on the PIN gate (`NetworkAccessMiddleware`, `backend/main.py`):
|
|
|
|
- It covers **HTTP only** — it does **not** gate WebSockets. All WebSocket
|
|
routes have their own shared guard (see below), and the PIN does **not**
|
|
authorize them; use an administrator credential or a trusted network.
|
|
- The SPA shell (`/`, `/index.html`, `/favicon*`, `/assets/*`, `/health`) is
|
|
always served un-PIN'd so the PIN-prompt UI can load.
|
|
- It is a **consumption** credential: a valid PIN never unlocks the admin surface
|
|
(it is 6 digits, brute-forceable). Admin needs loopback or the API key.
|
|
- It is completely inert when no PIN is set (including Docker until in-app
|
|
network sharing is enabled). Docker's bridge can make the host's own browser
|
|
a non-loopback client; if the PIN is lost, follow the
|
|
[Docker recovery steps](install/docker.md#recovering-from-a-lost-share-pin).
|
|
|
|
---
|
|
|
|
## API key
|
|
|
|
Export history (`GET /export/history`, `POST /export/record`) accepts local
|
|
clients and authenticated remote consumers, including API-key sessions and
|
|
share-PIN guests. Anonymous remote callers are rejected. Recording an export
|
|
only stores metadata; `/export` and `/export/reveal` still require native local
|
|
access, and deleting history retains its administrator boundary. Explicit server
|
|
mode without a configured key or PIN keeps its existing open consumption policy
|
|
for export metadata, with destination paths returned only to the principals the
|
|
desktop itself uses — loopback, an API key, or an admin session — so a browser on
|
|
the trusted network or a PIN guest gets an empty string; a remote caller holding
|
|
one of those credentials is treated the same as the desktop, because the
|
|
credential is what identifies it. The operator's port mapping controls access in
|
|
that mode.
|
|
|
|
The API key is the backend's durable root credential for a GPU box, Docker
|
|
container, or reverse-proxied host. Direct API clients may send it on each
|
|
request. The first-party browser/Electron UI instead exchanges it once for a
|
|
short-lived administrator session and never stores the master. Set it on the
|
|
**backend** process:
|
|
|
|
```bash
|
|
# Generate a strong key and start the backend with it
|
|
export OMNIVOICE_API_KEY="$(python -c 'import secrets; print(secrets.token_urlsafe(24))')"
|
|
uv run uvicorn backend.main:app --host 0.0.0.0 --port 3900
|
|
# Docker: pass -e OMNIVOICE_API_KEY=…
|
|
```
|
|
|
|
While `OMNIVOICE_API_KEY` is set, every **non-loopback HTTP and WebSocket**
|
|
request must present an accepted credential. SPA shell paths remain public;
|
|
`POST /api/auth/session` passes through the middleware only so its route can
|
|
validate the master and perform the one-time exchange. Direct-client
|
|
compatibility accepts:
|
|
|
|
| Where | How |
|
|
|---|---|
|
|
| Header | `Authorization: Bearer <key>` — **preferred** for scripts and SDKs |
|
|
| Header (ElevenLabs routes) | `xi-api-key: <key>` — accepted only on `/elevenlabs` routes, for [ElevenLabs SDKs](elevenlabs-api.md) |
|
|
| Legacy cookie | `ov_key=<key>` — accepted only for compatibility and migrated by the first-party UI; the backend no longer creates it |
|
|
| Legacy query param | `?api_key=<key>` — compatibility only. **A key in a URL leaks into proxy/access logs and browser history** |
|
|
|
|
```bash
|
|
# Prefer an encrypted transport (Tailscale Serve / TLS) for a real key; plain
|
|
# http:// on an untrusted network exposes the Bearer token on the wire.
|
|
curl https://gpu-box:3900/v1/audio/speech \
|
|
-H "Authorization: Bearer $OMNIVOICE_API_KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"model":"tts-1","voice":"alloy","input":"Hello from a keyed backend.","response_format":"wav"}' \
|
|
--output speech.wav
|
|
```
|
|
|
|
```python
|
|
# The OpenAI SDK sends the key as a Bearer token automatically
|
|
from openai import OpenAI
|
|
|
|
client = OpenAI(
|
|
base_url="https://gpu-box:3900/v1",
|
|
api_key="<your OMNIVOICE_API_KEY>", # must match OMNIVOICE_API_KEY on the backend
|
|
) # (any string works ONLY when no key is set — the loopback default)
|
|
audio = client.audio.speech.create(
|
|
model="tts-1", voice="alloy", input="Hello from a keyed backend.",
|
|
response_format="wav",
|
|
)
|
|
audio.write_to_file("speech.wav")
|
|
```
|
|
|
|
A missing or wrong key returns:
|
|
|
|
```
|
|
HTTP/1.1 401 Unauthorized
|
|
{"detail": "API key required"}
|
|
```
|
|
|
|
On a **WebSocket**, a missing or wrong key rejects the handshake before
|
|
acceptance with HTTP **403**, without a JSON body or a WebSocket close frame.
|
|
The guard's internal ASGI policy code is `1008`.
|
|
|
|
Notes on the API-key gate (`BearerKeyMiddleware`, `backend/main.py`):
|
|
|
|
- The key is compared in **constant time** and is **never logged**.
|
|
- The backend never copies the master into a response cookie. Browser clients
|
|
receive only `ov_session`, an opaque, HttpOnly, SameSite=Strict credential.
|
|
- The SPA shell paths bypass the gate on **HTTP** so a remote UI can load and
|
|
show what's wrong; WebSockets have no such exemption.
|
|
- **Plain HTTP is sniffable** — a Bearer key over `http://` on a hostile
|
|
network can be read off the wire. Use Tailscale (WireGuard) or TLS for
|
|
anything beyond a fully trusted LAN. See
|
|
[docs/remote-gpu.md](remote-gpu.md) for the full remote-backend setup.
|
|
|
|
### First-party administrator sessions
|
|
|
|
The bundled UI uses a narrower protocol:
|
|
|
|
1. `POST /api/auth/session` receives the master in an `Authorization` header
|
|
exactly once and selects `{"transport":"cookie"}` for exact same-origin
|
|
browsers or `{"transport":"bearer"}` for cross-origin clients (including
|
|
the Electron app's remote-backend connections).
|
|
2. Cookie transport returns `204` and sets `ov_session` as HttpOnly,
|
|
SameSite=Strict, path `/`, with an eight-hour maximum lifetime. Bearer
|
|
transport returns an opaque `ovs_admin_session_…` value which the UI keeps
|
|
in **localStorage**, bound to the exact backend base URL, so authenticated
|
|
reloads and new tabs reuse it until its bounded expiry. Bearer JSON
|
|
responses include both `expires_at` and a bounded `expires_in`; the UI uses
|
|
the relative lifetime when available so clock skew between a remote GPU host
|
|
and the browser cannot reject a valid session. `expires_at` remains for
|
|
backward compatibility with older clients and servers.
|
|
3. `DELETE /api/auth/session` revokes the session. Removing or rotating
|
|
`OMNIVOICE_API_KEY`, backend restart, explicit logout, and the eight-hour
|
|
deadline also invalidate it.
|
|
4. `GET /api/auth/whoami` reports the calling credential's tier as
|
|
`{"kind", "capabilities", "transport"}`, so a client (or an integration)
|
|
can ask what it may do instead of provoking a `403` on a real route. It
|
|
never echoes a token, a PIN, an API key or a session id. The route sits
|
|
behind the usual credential gates: when an API key or a share PIN is
|
|
configured, a remote caller with no credential gets `401` from the gate,
|
|
which is itself the answer (sign in first).
|
|
|
|
Choosing **Use local** discards the current stored bearer session, including
|
|
one created by testing an unsaved backend URL. The stored session is revoked
|
|
against its own backend, and the configured backend's cookie session is also
|
|
revoked on a best-effort basis. Stored credentials are cleared immediately;
|
|
the app reloads into local mode after both bounded revocation attempts finish.
|
|
|
|
The master is never written to localStorage/sessionStorage, never returned by
|
|
the backend, and never placed in a WebSocket URL. Legacy `ov_api_key` browser
|
|
storage is deleted before migration waits on the network. All auth responses,
|
|
including errors, carry `Cache-Control: no-store`.
|
|
|
|
Failed session exchanges are limited per client to ten attempts in a rolling
|
|
60-second window and then return `429` with `Retry-After`. A correct master key
|
|
is always evaluated and clears the failure window, so an attacker cannot lock
|
|
an operator out by deliberately exhausting the limit.
|
|
|
|
Cookie-authenticated mutations require both an exact allowed `Origin` and
|
|
`X-VoiceStudio-CSRF: 1`. Side-effectful GET actions additionally require the
|
|
browser's `Sec-Fetch-Site: same-origin`. Bearer/header clients are not subject
|
|
to the ambient-cookie CSRF check.
|
|
|
|
---
|
|
|
|
## WebSocket access
|
|
|
|
The live-dictation stream at **`ws://<host>:3900/ws/transcribe`**, its
|
|
`/v1/audio/transcriptions/stream` alias, streaming TTS at `/ws/tts`, and sidebar
|
|
events at `/ws/events` all await `require_ws_access` before accepting a socket,
|
|
in addition to the API-key middleware. This guard also applies when no API key
|
|
is configured. A non-loopback client reaches these routes only if it is either:
|
|
|
|
- on a [trusted network](#trusted-networks) (`is_local_host` passes), **or**
|
|
- presenting a direct-client **API key** in `Authorization`, or through a
|
|
legacy `ov_key`/`?api_key=` transport, or a valid administrator session or
|
|
path-bound one-shot ticket as described below.
|
|
|
|
A browser's supplied `Origin` is validated before any local/trusted-network or
|
|
credential admission. It must match the backend's origin or an entry in
|
|
`OMNIVOICE_ALLOWED_ORIGINS`; the default entries include `app://voicestudio`
|
|
and the localhost/127.0.0.1 UI origins. An origin outside these allowed values
|
|
is refused even on loopback or with a valid key. Native clients without an
|
|
`Origin` keep their credential and trusted network paths, except WebSocket
|
|
tickets, which require an allowed origin; browser session cookies also require
|
|
an allowed origin.
|
|
|
|
```
|
|
ws://gpu-box:3900/ws/transcribe?api_key=<key>
|
|
```
|
|
|
|
That URL form is retained for non-browser compatibility only. The first-party
|
|
UI never constructs it. A bearer administrator session first calls
|
|
`POST /api/auth/ws-ticket` and puts only the returned `ws_ticket` in the URL.
|
|
Tickets are scoped to one of `/ws/transcribe`, `/ws/events` or `/ws/tts` (the
|
|
live dub preview stream), expire after 30 seconds,
|
|
return the same bounded `expires_in`/`expires_at` pair, and are consumed
|
|
atomically at most once. Same-origin UI WebSockets use the
|
|
HttpOnly session cookie and must pass exact `Origin` validation; `null`, missing,
|
|
and lookalike origins are rejected.
|
|
|
|
The **share PIN does not authorize WebSockets** — the PIN gate is HTTP-only.
|
|
A LAN guest who has only entered a PIN can use the HTTP consumption API but
|
|
cannot use live dictation, streaming TTS or sidebar event updates. Configure an
|
|
administrator API key/session or an explicitly trusted network for those
|
|
streams. When neither a permitted credential nor a trusted network applies, the
|
|
guard refuses the handshake before accepting it. The ASGI refusal uses code
|
|
`1008` internally, but the server returns **HTTP 403**, without a WebSocket close
|
|
frame or reason. Browsers may expose only a generic connection failure (`1006`).
|
|
|
|
---
|
|
|
|
## Trusted networks
|
|
|
|
`OMNIVOICE_TRUSTED_NETWORKS` is a comma-separated list of **CIDR ranges** whose
|
|
clients are treated as loopback-trusted by the **consumption** gates — so a
|
|
reverse proxy or a trusted LAN/Tailnet can reach the API **without a PIN or key**
|
|
(useful when a proxy strips the `Authorization` header). Such requests are still
|
|
host-checked: a proxy that forwards the original `Host` (Caddy and Nginx Proxy
|
|
Manager do) needs its host name in `OMNIVOICE_ALLOWED_HOSTS`, as does any
|
|
other name clients use besides an IP address, `localhost`, this machine's name
|
|
or a `*.ts.net` name — see [host names](#requests-from-other-websites-and-host-names).
|
|
|
|
```bash
|
|
export OMNIVOICE_TRUSTED_NETWORKS="192.168.1.0/24,10.0.0.0/8"
|
|
```
|
|
|
|
What it exempts vs. what it does not:
|
|
|
|
- **Exempts** (via `is_local_host`, `backend/api/dependencies.py`): the share
|
|
PIN gate, the API-key gate, and the dictation WebSocket guard. Clients in a
|
|
listed range need no PIN or key for these **consumption** routes.
|
|
- **Never exempts admin.** `/system/*` and `/api/settings/*` are the RCE-class
|
|
admin surface; trusted-network membership is a *consumption* exemption and
|
|
does not reach them — even under `OMNIVOICE_SERVER_MODE=1`. See
|
|
[Admin routes](#admin-routes-and-server-mode).
|
|
|
|
Details: malformed CIDR entries are silently ignored (a bad entry never wedges
|
|
the gate); IPv4-mapped IPv6 addresses (`::ffff:192.168.1.5`) from dual-stack
|
|
proxies are unwrapped so they match IPv4 CIDRs; the value is read at request
|
|
time, so in production **restart the backend** to apply a change. Default empty
|
|
— no change to the strict loopback default.
|
|
|
|
### Docker host loopback
|
|
|
|
`OMNIVOICE_TRUST_HOST_LOOPBACK=1` (server mode only) lets the Docker host's own
|
|
browser skip the **share PIN**. Inside the container that browser arrives from
|
|
the default gateway, so only that exact socket address qualifies, only on the
|
|
main port (not the LAN-share listener), and forwarded headers are never read
|
|
for it. It grants the PIN's consumption rights only: the API-key gate and admin
|
|
routes are unaffected. Default off. Risks and setup:
|
|
[Docker install](install/docker.md#trust-host-loopback).
|
|
|
|
---
|
|
|
|
## Admin routes and server mode
|
|
|
|
Admin routes — `/system/*` (including `set-env`, **RCE-class**),
|
|
`/api/settings/*`, engine selection/install/uninstall, media tools, MCP
|
|
bindings and pronunciation settings — sit on a
|
|
stricter gate (`require_admin`, `backend/api/dependencies.py`) than consumption.
|
|
Editing, deleting and importing stored content (voice/profile, project,
|
|
glossary, persona, watermark settings, marketplace, batch-job delete) also uses
|
|
this admin gate. Their read-only metadata and saved audio remain available to
|
|
authenticated consumers, including PIN-paired phones, and so do the routes that
|
|
only run a generation (translate, dub, dub abort, batch submit/cancel/retry, voice convert,
|
|
capture, describe voice, audiobook render, clone creation), marked with
|
|
`@consumer_generation`. The OpenAI-compatible
|
|
`/v1` API retains its consumption gate. A pending designed-voice preview can
|
|
synthesize and save audio even though it is a GET, so it requires an admin
|
|
credential too. Same-origin media requests can use an admin-session cookie
|
|
without the JavaScript CSRF header; cross-site GETs remain rejected.
|
|
|
|
On the desktop build they are **true-loopback-only**: no PIN, key, or trusted
|
|
network reaches them from another machine.
|
|
|
|
In **server mode** (`OMNIVOICE_SERVER_MODE=1`, the Docker image) the loopback
|
|
origin is unenforceable — NAT rewrites the source and even a
|
|
`-p 127.0.0.1:3900:3900` mapping looks non-loopback — so the true-loopback
|
|
requirement is dropped (issue #261, else the operator is 403'd out of their own
|
|
`/system/*`). It is replaced by a **credential rule**, not removed:
|
|
|
|
- **No credential configured** (neither API key nor share PIN) → read-only
|
|
admin discovery remains available for the bare Docker bootstrap flow, but
|
|
`POST`/`PUT`/`PATCH`/`DELETE` requests are denied. Side-effectful GET actions
|
|
are denied too: engine health may start a sidecar, deep diagnostics may load
|
|
a model, and LLM provider discovery makes a request with the saved provider
|
|
credential. Set `OMNIVOICE_API_KEY` before changing settings or triggering
|
|
those actions remotely.
|
|
- **An API key is configured** → admin requires that **API key** (direct-client
|
|
`Authorization` / legacy query or cookie), a valid short-lived administrator
|
|
session, or genuine loopback. The **6-digit share PIN does not gate admin**
|
|
(it is brute-forceable), and trusted-network membership never does either. A
|
|
**PIN-only** server-mode deployment therefore keeps admin routes loopback-only;
|
|
remote admin starts from the long API key.
|
|
|
|
Managed sidecar installation remains true-loopback-only even with an API key.
|
|
Its installer fetches mutable source and creates an editable environment, so it
|
|
must be run directly on that machine until the source supply chain is pinned.
|
|
|
|
Runtime logs, the log stream, recent errors and the last-run crash report do
|
|
not use the bare-server discovery exemption. They can contain host paths and
|
|
diagnostic details, so remote server-mode reads require the administrator API
|
|
key or a valid administrator session. A share PIN or trusted network alone does
|
|
not authorize them. Genuine loopback reads remain available without a key;
|
|
cross-site browser reads are refused.
|
|
|
|
Host paths are never selected through HTTP. The Electron main process validates
|
|
model-cache and export destinations (chosen in a native save/open dialog) plus
|
|
custom FFmpeg/FFprobe binaries, writes a private one-shot capability, and only
|
|
that opaque authorization reaches the backend. `/export` therefore accepts an `authorization` token, never a
|
|
`destination_path`; revealing an arbitrary exported path runs in the native
|
|
process, while the HTTP fallback is limited to the server-owned data root.
|
|
`/system/set-env` does not accept executable-path keys at all, and sidecar
|
|
engine folders (`OMNIVOICE_*_DIR`, whose interpreter the backend runs) are set
|
|
in the env file (or left unset); the HTTP API can only clear them. Server mode and
|
|
an API key do not weaken that native boundary.
|
|
|
|
This is the fix for a real escalation (#1213): before it, server mode made the
|
|
admin gate a no-op, so with an API key set *and* a trusted CIDR configured, a LAN
|
|
client in that CIDR could `POST /system/set-env` — RCE-class — with **no
|
|
credential at all**, because the API-key middleware waved it through as
|
|
`is_local_host`. Now the admin gate is independent of the consumption exemptions.
|
|
|
|
---
|
|
|
|
## Browsers from another origin (CORS)
|
|
|
|
Everything above gates *authentication*. A **browser** frontend served from a
|
|
different origin than the backend hits a separate wall first: CORS. The
|
|
backend's allow-list defaults to loopback + the desktop origin only
|
|
(`http://localhost:<ui-port>`, `http://127.0.0.1:<ui-port>`,
|
|
`app://voicestudio`), so opening a dev/source UI via
|
|
a LAN IP (e.g. `http://192.168.1.159:3901` talking to `…:3900`) blocks every
|
|
request with *"Missing Header: Access-Control-Allow-Origin"* — regardless of
|
|
`OMNIVOICE_SERVER_MODE` or `OMNIVOICE_TRUSTED_NETWORKS`, neither of which
|
|
touches CORS (#1348).
|
|
|
|
Add the exact origin the browser shows in its address bar:
|
|
|
|
```bash
|
|
export OMNIVOICE_ALLOWED_ORIGINS="http://192.168.1.159:3901,http://localhost:3901,http://127.0.0.1:3901,app://voicestudio"
|
|
```
|
|
|
|
Each entry must be a bare origin — `scheme://host:port`, exactly what the
|
|
browser sends in its `Origin` header — with no path and no trailing slash
|
|
(`http://192.168.1.159:3901/` would never match). The variable **replaces**
|
|
the default list, so restate the loopback and `app://voicestudio` origins
|
|
alongside your own. A refused request's 403 names its origin and gives the full
|
|
`OMNIVOICE_ALLOWED_ORIGINS=` line to add, defaults included. In the desktop
|
|
app, put it in `~/.config/omnivoice/env` (macOS, Linux) or
|
|
`%USERPROFILE%\.config\omnivoice\env` (Windows) and restart VoiceStudio. (The in-app LAN share and Tailscale flows in
|
|
[docs/sharing.md](sharing.md) don't need this — they serve UI and API from the
|
|
same origin.) If you only moved the Vite dev server's port, set
|
|
`OMNIVOICE_UI_PORT` (the older `VOICESTUDIO_UI_PORT` name is still accepted)
|
|
instead; both Vite and the default list follow it.
|
|
|
|
CORS wraps both authentication gates: credentialless browser preflights are
|
|
answered before PIN/API-key enforcement, and gate-generated `401` responses
|
|
retain CORS headers so the UI can read the actual failure and prompt for the
|
|
right credential.
|
|
|
|
Uvicorn applies proxy-header rewrites only for peers in its
|
|
`--forwarded-allow-ips` list (loopback by default), which covers bare-metal
|
|
Tailscale Serve. Docker can present the proxy as a bridge gateway instead.
|
|
VoiceStudio's effective-scheme helper also permits a one-way upgrade to HTTPS
|
|
from `X-Forwarded-Proto`; it never uses that header to downgrade HTTPS. This
|
|
supports exact-Origin checks and adds the session cookie's `Secure` attribute
|
|
without trusting the proxy's claimed client address. The header does not prove
|
|
that TLS or certificate validation succeeded: verify the client-facing HTTPS URL
|
|
in the browser. Do not set `FORWARDED_ALLOW_IPS=*` or trust a shared Docker gateway
|
|
merely to make sharing work. If original client-address forwarding is needed,
|
|
trust only a controlled proxy that sanitizes those headers and cannot be
|
|
bypassed. See [Docker with Tailscale](install/docker.md#private-remote-access-with-tailscale).
|
|
For a public path prefix such as `/studio`, either strip that prefix before
|
|
forwarding or configure the ASGI `root_path` to the same value. WebSocket ticket
|
|
validation removes only that trusted, configured prefix; it never accepts an
|
|
arbitrary path merely because it ends in `/ws/events`, `/ws/transcribe` or
|
|
`/ws/tts`.
|
|
|
|
## Requests from other websites and host names
|
|
|
|
Independently of every gate above, the backend refuses two kinds of browser
|
|
traffic in **every** configuration, loopback included:
|
|
|
|
- **Requests another website sends.** A state-changing request (`POST`, `PUT`,
|
|
`PATCH`, `DELETE`) or WebSocket handshake whose `Origin` is not allowed is
|
|
refused with HTTP `403` (including a WebSocket handshake before acceptance), as is one whose
|
|
`Sec-Fetch-Site` is `cross-site` or `same-site` without an allowed `Origin`.
|
|
Browsers send no `Origin` on media and download `GET`s (`<video src>`,
|
|
download links); those pass when their `Referer` is an allowed origin, and a
|
|
missing or foreign `Referer` is refused.
|
|
`GET` routes that start work or reach outside the machine refuse cross-site
|
|
`Sec-Fetch-Site` too: dub downloads and exports (video, audio, MP3, stems,
|
|
segment clips), dub segment and video previews, transcription streams, voice
|
|
and archetype previews, Ogg/Opus encoding of generated audio, history,
|
|
profile-image search, community catalog reads, setup preflight, model access
|
|
checks, storage rescans, Hugging Face token checks, LLM provider model
|
|
lists, Tailscale status, engine health and disk-usage checks, and
|
|
diagnostics. Ordinary navigation to the UI is unaffected.
|
|
Allowed origins are this backend's own
|
|
origin, `app://voicestudio` and the `OMNIVOICE_ALLOWED_ORIGINS` list
|
|
(see [CORS](#browsers-from-another-origin-cors)). Clients that send no
|
|
`Origin` and no `Sec-Fetch-Site` — scripts, curl, SDKs, MCP clients, the
|
|
desktop app's own process — are not affected.
|
|
- **Unrecognized host names.** A request that only network position
|
|
authorizes (loopback, a trusted network, or any client when no API key is
|
|
set) and carries no valid credential must address the backend by an IP
|
|
address, `localhost` / `*.localhost`, this machine's host name, a Tailscale
|
|
MagicDNS name (`*.ts.net`), a container host alias (`host.docker.internal`,
|
|
`gateway.docker.internal`, `host.containers.internal`), or a host named in
|
|
`OMNIVOICE_ALLOWED_HOSTS`, `OMNIVOICE_ALLOWED_ORIGINS`,
|
|
`OMNIVOICE_MCP_ALLOWED_HOSTS`, `OMNIVOICE_API_URL`,
|
|
`OMNIVOICE_PUBLIC_API_BASE` or `OMNIVOICE_BIND_HOST`. This stops a web page
|
|
from re-pointing its own domain at `127.0.0.1` (DNS rebinding). A request
|
|
that presents a valid API key or administrator session (including a WebSocket
|
|
ticket) is never host-checked, whatever its peer address — so
|
|
Caddy or cloudflared on the same machine can forward the original `Host`
|
|
with the client's key. A wrong or missing credential, or a share PIN alone, gets no such pass. The
|
|
UI shell, its assets and the session exchange are not host-checked either,
|
|
so a remote UI on any host name can still load and sign in. To reach the
|
|
backend by another name without a credential — a reverse proxy that keeps
|
|
the original `Host`, or a Docker host opened as `http://nas.lan:3900` — list
|
|
it:
|
|
|
|
```bash
|
|
export OMNIVOICE_ALLOWED_HOSTS="nas.lan,.home.example" # ".suffix" allows subdomains
|
|
```
|
|
|
|
The packaged desktop app has no Settings field for this. Add the same line
|
|
without `export` (`OMNIVOICE_ALLOWED_HOSTS=nas.lan`) to the user env file —
|
|
`~/.config/omnivoice/env` on macOS and Linux,
|
|
`%USERPROFILE%\.config\omnivoice\env` on Windows, or the file named by
|
|
`OMNIVOICE_ENV_FILE` — and restart VoiceStudio. Docker takes it as
|
|
`-e OMNIVOICE_ALLOWED_HOSTS=...`.
|
|
|
|
`OMNIVOICE_ALLOWED_HOSTS=*` turns the host check off; use it only behind a
|
|
proxy that validates `Host` itself. Browser extensions or other web apps that
|
|
call the API directly need their origin in `OMNIVOICE_ALLOWED_ORIGINS`.
|
|
|
|
## Status codes
|
|
|
|
| Code | Meaning | What to do |
|
|
|---|---|---|
|
|
| **401** | Consumption auth failed — `{"detail": "PIN required"}` or `{"detail": "API key required"}`. | Supply the PIN / key (header, cookie, or query param above). A refused WebSocket handshake returns HTTP **403**; browsers may expose a generic connection failure. |
|
|
| **403** | Authorization failed: the request came from another website or used an unrecognized host name ([details](#requests-from-other-websites-and-host-names)), loopback/native access was required, cookie Origin/CSRF validation failed, a server-mode mutation lacked an admin credential, or a native path capability was invalid/expired. | A PIN cannot grant admin or filesystem access. Re-authenticate the UI; scripts should use the API-key header; run native operations from the desktop app. The admin gate names the key only when one can satisfy it: server mode with `OMNIVOICE_API_KEY` configured answers `{"detail": "loopback origin or admin API key required"}` (the bundled UI routes it to the API-key login form); PIN-only/no-key server mode and the desktop build answer `{"detail": "loopback origin required"}` (only loopback can satisfy the gate). |
|
|
| **429** | A failed administrator-session exchange exceeded its per-client limit, the GPU pool is saturated, or a model download is rate-limited. Ships with `Retry-After`; workload throttles also carry `X-VoiceStudio-Retryable: true`. | Back off for `Retry-After` seconds. For authentication, verify the master before retrying; a correct master is never locked out. |
|
|
|
|
---
|
|
|
|
## See also
|
|
|
|
- [docs/remote-gpu.md](remote-gpu.md) — end-to-end remote-backend setup over
|
|
Tailscale, with the API key.
|
|
- [docs/sharing.md](sharing.md) — the in-app LAN share + PIN flow.
|
|
- [docs/agentic-voice.md](agentic-voice.md) — pointing OpenAI-compatible agent
|
|
frameworks at VoiceStudio.
|
|
- [docs/mcp.md](mcp.md) — the MCP server for AI agents.
|
|
|
|
|
|
## Gallery permissions
|
|
|
|
Gallery browsing and preview requests use the consumption gate. Importing,
|
|
uploading, editing, deleting or copying a gallery voice into a profile requires
|
|
administrator authorization. A share PIN alone does not authorize those
|
|
mutations; server deployments must configure an API key for remote management.
|