Open History to see the last commit
1# Environment authentication
2
3The environment issues its own sessions and enforces their capabilities. Cloud
4identity and relay credentials belong to a separate trust boundary, described in
5[T3 Connect](./t3-connect.md). A relay token is never an environment login.
6
7## Authority survives transport changes
8
9Pairing delegates a set of scopes. Exchanging a bootstrap credential can narrow
10that grant but cannot widen it. Ordinary pairing does not grant access-management
11or relay-management authority. Creating another pairing link requires both
12`access:write` and every scope being delegated. The
13[auth handlers](../../apps/server/src/auth/http.ts) enforce this at issuance;
14client labels and device metadata have no authorization role.
15
16The access read model contains pairing metadata, never recoverable pairing
17secrets. Only the creation response returns the raw credential. Otherwise read
18access to the connections list would become a way to acquire another client's
19authority.
20
21Browser cookies, bearer tokens, and DPoP tokens adapt the same scoped session
22model. DPoP binds a token to a client's proof key; an invalid proof must fail
23rather than fall back to bearer authentication. The OAuth token-exchange
24vocabulary gives these grants a familiar meaning, but the environment does not
25implement a general-purpose OAuth authorization server.
26
27Bearer and DPoP clients obtain short-lived WebSocket tickets through authenticated
28HTTP so long-lived tokens stay out of socket URLs. Browser sessions can
29authenticate the upgrade with their cookie. A successful handshake grants no
30extra authority: [every RPC declares a required
31scope](../../apps/server/src/auth/RpcAuthorization.ts).
32
33Desktop restarts forget the previous local bearer token, so its reusable
34bootstrap grant replaces earlier sessions for the same subject and method.
35Revocation and insertion share a [database
36transaction](../../apps/server/src/persistence/AuthSessions.ts); a failed
37replacement must leave the old credential usable. Pairing and browser sessions
38do not follow this replacement rule.
39
40## The environment is the filesystem boundary
41
42Projects are organizational boundaries, not filesystem sandboxes.
43`orchestration:read` permits reading files the server account can read, including
44absolute paths outside a project. This lets clients display artifacts that an
45agent writes in a temporary directory. Relative paths and writes still follow
46the [workspace path rules](../../apps/server/src/workspace/WorkspaceFileSystem.ts).
47
48Signed asset URLs are bearer credentials. A URL for media on the host grants
49access to one canonical file and its device/inode identity, not its containing directory.
50[Asset access](../../apps/server/src/assets/AssetAccess.ts) rechecks the opened
51file's identity when serving it, so atomic replacement requires a new URL while
52editing the same file in place does not. An HTML file authorized this way cannot
53load sibling assets; directory-scoped workspace previews are a separate grant.
54Clients should share the authored file reference so they do not disclose the
55temporary URL's credential.
56
57Host videos can change in place. Their [HTTP
58responses](../../apps/server/src/http.ts) omit cache validators because file
59metadata cannot prove byte-for-byte identity for `If-Range`. Adding weak
60validators would turn native-player seeks into full downloads.