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
11 changes: 9 additions & 2 deletions docs-developers/architecture/cross-repo-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@ and two URL carriers.
store apps claim no domain (only a build named in `app_links` does).
- `uri` (`audiosilo://connect?server=<base>&token=<pairing_token>`) uses the custom
scheme.
- Both links and the invite URL use `public_url` when set. With it empty,
a request from a trusted proxy reporting HTTPS gives them an HTTPS base
at the request's `Host`. See the [pairing response](../server/api/reference.md#post-apiv1authredeem).
- The flow is `POST /auth/redeem` (a code for a pairing payload), then
`POST /auth/exchange` (a pairing token for a device-scoped session). The
player sends its per-address sign-in key as `device_id`. If an invite
Expand Down Expand Up @@ -537,7 +540,7 @@ Every pairing payload (`/auth/redeem`, `/auth/pair`, the demo session's `pairing
may carry `addresses: { home?, away? }` (the `addresses` capability).

- `away` is `public_url`.
- `home` is `lan_url`, or else the request's own `Host` when that is a home-network
- `home` is `lan_url`, or else the address of a direct request to a home-network
host (`config.Addresses`). The host rule is in
[Configuration](../server/configuration.md#home-address-lan_url).
- The server drops a home equal to the away.
Expand All @@ -555,7 +558,11 @@ On the frontend:
- `parsePairingScan` returns `addresses`.
- The connect flow stores them on the connection (`Connection.addresses`).
`mergeAddresses` keeps a known `home` that an answer lacks.
- `serverUrl` is never rewritten.
- Only a sign-in rewrites `serverUrl`. For the same server and account it can
upgrade a saved HTTP `serverUrl` to HTTPS, never back, and can keep the old
HTTP address as an empty `home`. Within one scheme, a newly entered address
replaces it. The rules are in
[What a sign-in stores](../frontend/connect-and-addresses.md#what-a-sign-in-stores-repairplan).
- The native app picks the address per request. It uses home only after a tokenless
`GET <home>/api/v1/server` answered with this connection's `server_id`, else away,
else `serverUrl`.
Expand Down
5 changes: 4 additions & 1 deletion docs-developers/bridge/pairing-and-jobs.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ sequenceDiagram
already paired keeps working until a new Bridge exchanges the code. The answer's
`server_url` is the address to give the Bridge: the server's home address when
it has one (plain `http` on the local network for a self-signed server, whose
certificate the Bridge can't verify), else its public or request address.
certificate the Bridge can't verify). Without a home address, the server
uses `public_url` if set. Otherwise it uses its direct base at the request's
`Host`, ignoring a proxy's report of HTTPS. See the
[Bridge pairing response](../server/api/reference.md#post-apiv1adminbridgepair).
2. **The Bridge exchanges it** at the public `POST /bridge/pair`, which shares the
per-address failure limit of `POST /auth/redeem`. In **one transaction** the
server checks the code, its expiry and that the admin who made it is still an
Expand Down
39 changes: 29 additions & 10 deletions docs-developers/frontend/connect-and-addresses.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,16 @@ Two sign-ins skip `finishConnect`:

### What a sign-in stores (`repairPlan`)

`repairPlan` decides what a sign-in stores:

- **The same connection again**, when its `server_id` answered through one of its own
addresses. Keep its paired `serverUrl`. The reconnect banner signs in through the
address in use now, which away from home is the away address.
`repairPlan` chooses the saved address from the server and account that answered.

- **The same server and account.** When `server_id` and the signed-in user match,
the player keeps the connection id, its downloads, listening places and settings.
- A sign-in at an HTTPS address upgrades a saved HTTP `serverUrl`, even when
the connection already knows the HTTPS address as `away`.
- Signing in at the connection's known `home` keeps the saved URL. If a
pairing link only succeeds at its HTTP home, it leaves a saved HTTP URL in place.
- Signing in over HTTP keeps a saved HTTPS URL. Within the same scheme,
a sign-in at a known address keeps the saved URL and a new address can replace it.
- **A reset server**, when the banner's connection, reached through one of its own
addresses, answers with a new `server_id`. Store the old connection's `serverUrl` and
carry its addresses over; the home address is probed against the new id before it is
Expand All @@ -437,7 +442,19 @@ Two sign-ins skip `finishConnect`:
`server-reset`, for them to sign in again. At a home-network address they stay
unflagged, since another box can answer there on another network
([Session](state-and-data.md#session-srcstoressessionts)).
- **Anything else**: store the address signed in through.
- **Another account on the same server.** It gets its own connection. When it
signs in through a known address, it can reuse the server address from another
account on the device.
- **A remembered server.** After sign-out, signing in at a known address for
the same server can reuse its remembered URL. Otherwise a new connection
stores the address from the sign-in.

`setSession` applies `savedUrlAfterSignIn` to the connection it finds when it
writes, so overlapping sign-ins keep the HTTPS upgrade. After merging the known
and returned addresses, `addressesAfterUpgrade` can fill an empty `home` with
the old HTTP URL. It does this only if `looksLikeHomeAddress` recognizes the old
address as local and the new HTTPS address as nonlocal. The usual
[home address check](#the-pick-rule-srclibserver-addressts) runs before the app uses it.

### The bounce, the reconnect banner and the screens

Expand Down Expand Up @@ -492,7 +509,8 @@ scheme, normalised, and `home` is dropped when it equals `away`.
what the connection had, so a `home` survives an answer read away from home. The
remembered server (`known-servers.ts`, `rememberAddresses`) learns the merge too, so a
reconnect after signing out can still start at home.
- **`serverUrl` is never rewritten.** It stays what the listener paired with or typed.
- Automatic switching picks an address in memory. A [sign-in](#what-a-sign-in-stores-repairplan)
can update the saved `serverUrl`.

### The pick rule (`src/lib/server-address.ts`)

Expand Down Expand Up @@ -552,9 +570,10 @@ when all of these hold:
- A tokenless `GET <home>/api/v1/server` answers with exactly that id.

The app then uses the verified home's sign-in key for the exchange and any
retry. The exchange's own `server_id` must match too. The connection is stored with the https
base as `serverUrl`, which fails safely by TLS on another network, and the home as its
address. `finishConnect` sets the home pick (`answeredAt`) before the connection is
retry. The exchange's own `server_id` must match too. For a first pairing, the app
saves the HTTPS base as `serverUrl` and the verified HTTP address as `home`; a
later sign-in follows [What a sign-in stores](#what-a-sign-in-stores-repairplan).
`finishConnect` sets the home pick (`answeredAt`) before the connection is
stored, so its first requests go home. The address runner then keeps that pick by the
usual probe.

Expand Down
6 changes: 4 additions & 2 deletions docs-developers/frontend/state-and-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -1647,8 +1647,10 @@ The session store holds several connections. A `Connection` is
[Connection identity](#connection-identity-server_iduser_id)). It keys every
per-connection store.
- `serverId` is the server's `server_id`, read through `serverIdOf(conn)`.
- `serverUrl` is the address the listener paired with or typed. It is never
rewritten.
- `serverUrl` is the connection's saved address. Only a sign-in rewrites it: a
sign-in to the same server and account can upgrade it from HTTP to HTTPS, never
back, and within one scheme a newly entered address replaces it (see
[What a sign-in stores](connect-and-addresses.md#what-a-sign-in-stores-repairplan)).
- `addresses` holds the server's home and away addresses (capability
`addresses`). Which one requests go to right now is an in-memory pick, never
stored (see
Expand Down
5 changes: 5 additions & 0 deletions docs-developers/server/api/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ Additions:

Changes to existing routes:

- With `public_url` empty, `POST /auth/redeem`, `POST /auth/pair` and the
pairing in `POST /demo/session` use an HTTPS `base_url` when a trusted proxy
reports HTTPS. The QR code's `web_url`, the app link's `server` parameter,
`links.web` and `links.admin` use that base. See the
[pairing response](reference.md#post-apiv1authredeem).
- With `include=previous`, `GET /libraries/{id}/meta` waits at most five
seconds for the earlier works and returns those ready by then, where it used
to wait for all of them. `previous` can hold fewer works, or be absent. See
Expand Down
48 changes: 28 additions & 20 deletions docs-developers/server/api/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,12 @@ The other fields:
or an admin's recovery code), so the connect page offers the console only to
an admin. It is absent for a listener's code, and on every other pairing
payload (`/auth/pair`, the demo).
- `base_url` honors the configured `public_url`, falling back to the request host.
- `base_url` uses `public_url` when set. Otherwise it uses the request's `Host`.
If the direct peer is in `trusted_proxies` and reports HTTPS, the base is
`https://<Host>` even when the proxy reaches the server over HTTP (which
headers count is in [Server and network configuration](../configuration.md#server--network)).
Otherwise (an untrusted peer, or no clear HTTPS report) it uses the direct connection rules. `web_url`, the `server` parameter in `uri`, `links.web` and `links.admin`
all use this base.
- `server_name` is the server's display name, as `GET /server`'s `name`.
- `server_id` is its stable id, as `GET /server`'s `server_id`. Both links end with
that id as `sid=`, after the address params described in
Expand Down Expand Up @@ -406,9 +411,9 @@ is then `http://` even when the request came over https:
`http://192.168.1.20:8080`.
- An https request without a port gets `http://<host>:443`, the port that answers.

`base_url`, `web_url` and the `uri`'s `server=` stay https, even for a pairing asked
for over plain HTTP. They use the https base on the same port, or `:80` for a Host
without one. A link then reads
When `public_url` is empty, `base_url`, `web_url` and the `uri`'s `server=` stay
HTTPS even for a direct pairing request over plain HTTP. They use HTTPS on that same
port, or `:80` for a direct HTTP request whose `Host` has no port. A link then reads
`…server=https%3A%2F%2F192.168.1.20%3A8080&token=…&home=http%3A%2F%2F192.168.1.20%3A8080&sid=…`.

A native app that can't trust the certificate at `server` exchanges the token at that
Expand Down Expand Up @@ -570,8 +575,9 @@ device from an existing session. The body is optional:
{ "ttl_seconds": 120 }
```

Response `200`: a `PairingPayload`, the same shape as `/auth/redeem` without the
invite budget fields and `admin`. Its token is single-use and lasts 10 minutes (`pairingTTL`),
Response `200`: a `PairingPayload` with the same fields and link base as
[`/auth/redeem`](#post-apiv1authredeem), excluding the invite budget fields and
`admin`. Its token is single-use and lasts 10 minutes (`pairingTTL`),
so the player counts down from when the payload arrived.

`ttl_seconds` (from 2.4.0) asks for a shorter life, clamped to 30 seconds through
Expand Down Expand Up @@ -6367,7 +6373,8 @@ logs; the connect page auto-redeems it client-side.

Creation and rotation include `external_https: true` when the configured
public URL uses HTTPS or, with no public URL, a trusted proxy reports HTTPS in
an unambiguous protocol header. Forwarding headers never change `invite_url`.
an unambiguous protocol header. `invite_url` uses the same base as the
[pairing payload](#post-apiv1authredeem).
What the console does with it is in [Admin web UI](../web-ui.md#people--people-invites-shares-and-devices).

`404` if the user doesn't exist. `409 code: "kid_account"` (`not available for a kid's
Expand Down Expand Up @@ -10663,8 +10670,8 @@ effect. Lists are never `null`.
| Field | Meaning |
|---|---|
| `general.name` | display name; `""` means `"AudioSilo"` (what `GET /server` then reports) |
| `general.public_url` | `""` = derived from each request's host |
| `general.lan_url` | the [home address](../configuration.md#home-address-lan_url); `""` = derived from a request on a home-network host |
| `general.public_url` | `""` = pairing and invite links use the request's `Host`, with HTTPS from a [trusted proxy](../configuration.md#server--network) |
| `general.lan_url` | the [home address](../configuration.md#home-address-lan_url); `""` = derived only from a direct request on a home-network host |
| `players.web_dir` | read-only: changed only in `config.yaml` or `AUDIOSILO_WEB_DIR` |
| `players.web_player` | read-only: where `/web` is served from - `"embedded"` (baked into the build), `"dir"` (from `web_dir`) or `""` (not mounted) |
| `metadata.region` | the preferred Audible marketplace (`""` = none; see [Configuration](../configuration.md#community-metadata-metadata)) |
Expand Down Expand Up @@ -11438,14 +11445,12 @@ server and this request:
not yet seen. A server with no row (a fresh one) answers `finished: false`,
`dismissed: false`, `steps: {}`; migration `0053` stored an upgraded server
as finished and dismissed.
- `request` is this request as the server saw it. The server never trusts
`X-Forwarded-Host` or `X-Forwarded-Proto`, so `host` (the `Host` header) and
`scheme` (`https` only for a TLS connection to the server itself) are the
direct connection's; the console compares them with the address the browser
uses. `proxied` is true when the request carried any forwarding header, and
only then is `peer` sent: the address that connected (the proxy), for
`network.trusted_proxies`. `peer_trusted` says whether that address is
already trusted.
- `request.host` comes from the `Host` header. `request.scheme` is `https` for
a TLS connection or when a trusted proxy reports HTTPS, and `http` otherwise.
The console compares that scheme and host with the browser's address.
When the request carries a forwarding header, `proxied` is true and
`peer` gives the address that connected to the server. `peer_trusted` says
whether that address is in `network.trusted_proxies`.
- `config_libraries` are the names of the libraries `config.yaml` or the
environment declares (re-added at every start). Each admin library row also
carries `from_config`.
Expand Down Expand Up @@ -11784,9 +11789,12 @@ code replaces one still waiting; a Bridge already paired keeps working until a n
one exchanges the code. `server_url` is the address to give the Bridge: the
server's [home address](#home-and-away-addresses) when it has one (its address on
the local network, plain `http` for a server with a self-signed certificate, which
a Bridge can't verify), else the address the server builds its links with (the
configured `public_url`, or the address the request came in on). Audited as
`bridge.code`.
a Bridge can't verify). Without a home address it uses `public_url` if set.
Otherwise the server uses the direct base at the request's `Host`, ignoring the
proxy's HTTPS report: for a TLS-off server behind a proxy that passes the public
`Host`, that is `http://books.example.com`. A Bridge beside the server usually
reaches it directly instead (such as `http://audiosilo:8080`), an address it is
given on its own side. The audit event is `bridge.code`.

| Status | Meaning |
|---|---|
Expand Down
Loading