The best way to control Claude Code, Codex and more from any computer or phone
feat(auth): pairing grants access and T3 Connect management by default (#20432)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 19:08 UTC
19108aa7b4f8cd16f366003f4021e3fbccd42cfa
16 files changed
+52
-64
apps/server/src/auth/EnvironmentAuth.test.ts
+8
-10
@@ -1,9 +1,5 @@
1
import * as NodeServices from "@effect/platform-node/NodeServices";
2
-import {
3
- authScopeResponse,
4
- AuthAdministrativeScopes,
5
- AuthStandardClientScopes,
6
-} from "@t3tools/contracts";
2
+import { authScopeResponse, AuthStandardClientScopes } from "@t3tools/contracts";
3
import { expect, it } from "@effect/vitest";
4
import * as Effect from "effect/Effect";
5
import * as Layer from "effect/Layer";
@@ -103,7 +99,7 @@ it.layer(NodeServices.layer)("EnvironmentAuth.layer", (it) => {
99
const authenticated = yield* serverAuth.authenticateHttpRequest(request);
100
expect(devExchange.cookieName).toMatch(/^t3_dev_session_/);
101
expect(devExchange.expireNormalCookie).toBe(true);
106
- expect(devExchange.response).toMatchObject(authScopeResponse(AuthAdministrativeScopes));
102
+ expect(devExchange.response).toMatchObject(authScopeResponse(AuthStandardClientScopes));
103
expect(authenticated.scopes).toEqual(["orchestration:read"]);
104
}).pipe(
105
Effect.provide(
@@ -253,7 +249,7 @@ it.layer(NodeServices.layer)("EnvironmentAuth.layer", (it) => {
249
expect((yield* Effect.flip(sessions.verify(token)))._tag).toBe("SessionTokenRevokedError");
250
expect(
251
(yield* serverAuth.createBrowserSession(recovery.credential, requestMetadata)).response,
256
- ).toMatchObject({ authenticated: true, ...authScopeResponse(AuthAdministrativeScopes) });
252
+ ).toMatchObject({ authenticated: true, ...authScopeResponse(AuthStandardClientScopes) });
253
}).pipe(
254
Effect.provide(
255
layerEnvironmentAuth({
@@ -362,7 +358,9 @@ it.layer(NodeServices.layer)("EnvironmentAuth.layer", (it) => {
358
it.effect("preserves pairing grants after rejecting scopes they do not grant", () =>
359
Effect.gen(function* () {
360
const serverAuth = yield* EnvironmentAuth.EnvironmentAuth;
365
- const pairingCredential = yield* serverAuth.issuePairingCredential();
361
+ const pairingCredential = yield* serverAuth.issuePairingCredential({
362
+ scopes: ["orchestration:read", "orchestration:operate"],
363
+ });
364
365
const error = yield* serverAuth
366
.exchangeBootstrapCredentialForAccessToken(
@@ -514,7 +512,7 @@ it.layer(NodeServices.layer)("EnvironmentAuth.layer", (it) => {
512
Effect.gen(function* () {
513
const serverAuth = yield* EnvironmentAuth.EnvironmentAuth;
514
const pairingCredential = yield* serverAuth.issuePairingCredential({
517
- scopes: AuthAdministrativeScopes,
515
+ scopes: AuthStandardClientScopes,
516
});
517
const listedPairingLinks = yield* serverAuth.listPairingLinks();
518
@@ -544,7 +542,7 @@ it.layer(NodeServices.layer)("EnvironmentAuth.layer", (it) => {
542
makeCookieRequest(sessions.cookieName, exchanged.sessionToken),
543
);
544
547
- expect(verified.scopes).toEqual(AuthAdministrativeScopes);
545
+ expect(verified.scopes).toEqual(AuthStandardClientScopes);
546
expect(verified.subject).toBe("administrative-bootstrap");
547
}).pipe(Effect.provide(layerEnvironmentAuth())),
548
);
apps/server/src/auth/EnvironmentAuth.ts
+2
-3
@@ -1,7 +1,6 @@
1
import {
2
AuthAccessTokenType,
3
AuthAccessWriteScope,
4
- AuthAdministrativeScopes,
4
AuthOrchestrationOperateScope,
5
AuthOrchestrationReadScope,
6
AuthSettingsWriteScope,
@@ -1096,7 +1095,7 @@ export const make = Effect.gen(function* () {
1095
.issue({
1096
subject: input?.subject ?? DEFAULT_SESSION_SUBJECT,
1097
method: "bearer-access-token",
1099
- scopes: input?.scopes ?? AuthAdministrativeScopes,
1098
+ scopes: input?.scopes ?? AuthStandardClientScopes,
1099
client: {
1100
...(input?.label ? { label: input.label } : {}),
1101
deviceType: "bot",
@@ -1151,7 +1150,7 @@ export const make = Effect.gen(function* () {
1150
const issueStartupPairingCredential: EnvironmentAuth["Service"]["issueStartupPairingCredential"] =
1151
() => {
1152
const fallback = issuePairingCredentialForSubject({
1154
- scopes: AuthAdministrativeScopes,
1153
+ scopes: AuthStandardClientScopes,
1154
subject: INTERNAL_ADMINISTRATIVE_BOOTSTRAP_SUBJECT,
1155
purpose: "startup",
1156
});
apps/server/src/auth/EnvironmentAuthAdmin.test.ts
+3
-3
@@ -1,4 +1,4 @@
1
-import { AuthAdministrativeScopes } from "@t3tools/contracts";
1
+import { AuthStandardClientScopes } from "@t3tools/contracts";
2
import * as NodeServices from "@effect/platform-node/NodeServices";
3
import { expect, it } from "@effect/vitest";
4
import * as Effect from "effect/Effect";
@@ -80,11 +80,11 @@ it.layer(NodeServices.layer)("EnvironmentAuth administrative operations", (it) =
80
const listedAfterRevoke = yield* environmentAuth.listSessions();
81
82
expect(issued.method).toBe("bearer-access-token");
83
- expect(issued.scopes).toEqual(AuthAdministrativeScopes);
83
+ expect(issued.scopes).toEqual(AuthStandardClientScopes);
84
expect(issued.client.deviceType).toBe("bot");
85
expect(issued.client.label).toBe("deploy-bot");
86
expect(verified.sessionId).toBe(issued.sessionId);
87
- expect(verified.scopes).toEqual(AuthAdministrativeScopes);
87
+ expect(verified.scopes).toEqual(AuthStandardClientScopes);
88
expect(verified.method).toBe("bearer-access-token");
89
expect(listedBeforeRevoke).toHaveLength(1);
90
expect(listedBeforeRevoke[0]?.sessionId).toBe(issued.sessionId);
apps/server/src/auth/McpOAuth.test.ts
+2
-2
@@ -1,6 +1,6 @@
1
import * as NodeServices from "@effect/platform-node/NodeServices";
2
import {
3
- AuthAdministrativeScopes,
3
+ AuthStandardClientScopes,
4
type AuthCreatePairingCredentialInput,
5
EnvironmentHttpApi,
6
} from "@t3tools/contracts";
@@ -502,7 +502,7 @@ it.live("one-click approves only access the browser session holds the scopes for
502
Effect.flatMap(json<{ csrfToken?: string; oneClickAccess?: ReadonlyArray<string> }>),
503
);
504
505
- const admin = yield* browserCookie([...AuthAdministrativeScopes]);
505
+ const admin = yield* browserCookie([...AuthStandardClientScopes]);
506
const adminDetails = yield* details(admin);
507
expect(adminDetails.csrfToken).toEqual(expect.any(String));
508
expect(adminDetails.oneClickAccess).toEqual([
apps/server/src/auth/PairingGrantStore.test.ts
+2
-2
@@ -1,4 +1,4 @@
1
-import { AuthAdministrativeScopes, AuthStandardClientScopes } from "@t3tools/contracts";
1
+import { AuthStandardClientScopes } from "@t3tools/contracts";
2
import * as NodeServices from "@effect/platform-node/NodeServices";
3
import { expect, it } from "@effect/vitest";
4
import * as Duration from "effect/Duration";
@@ -163,7 +163,7 @@ it.layer(NodeServices.layer)("PairingGrantStore.layer", (it) => {
163
const third = yield* bootstrapCredentials.consume("desktop-bootstrap-token");
164
165
expect(first.method).toBe("desktop-bootstrap");
166
- expect(first.scopes).toEqual(AuthAdministrativeScopes);
166
+ expect(first.scopes).toEqual(AuthStandardClientScopes);
167
expect(first.subject).toBe("desktop-bootstrap");
168
expect(second.method).toBe("desktop-bootstrap");
169
expect(third.method).toBe("desktop-bootstrap");
apps/server/src/auth/PairingGrantStore.ts
+2
-3
@@ -1,5 +1,4 @@
1
import {
2
- AuthAdministrativeScopes,
2
AuthStandardClientScopes,
3
type AuthEnvironmentScope,
4
type AuthPairingLink,
@@ -316,7 +315,7 @@ export const make = Effect.gen(function* () {
315
const now = yield* DateTime.now;
316
yield* seedGrant(config.desktopBootstrapToken, {
317
method: "desktop-bootstrap",
319
- scopes: AuthAdministrativeScopes,
318
+ scopes: AuthStandardClientScopes,
319
subject: "desktop-bootstrap",
320
expiresAt: DateTime.add(now, {
321
milliseconds: Duration.toMillis(DESKTOP_BOOTSTRAP_TTL_HOURS),
@@ -441,7 +440,7 @@ export const make = Effect.gen(function* () {
440
if (consumeRotatingDesktopToken(credential, now.epochMilliseconds)) {
441
return {
442
method: "desktop-bootstrap",
444
- scopes: AuthAdministrativeScopes,
443
+ scopes: AuthStandardClientScopes,
444
subject: "desktop-bootstrap",
445
expiresAt: DateTime.add(now, {
446
milliseconds: DESKTOP_BOOTSTRAP_TOKEN_WINDOW_MS,
apps/server/src/auth/SessionStore.ts
+1
-2
@@ -1,6 +1,5 @@
1
import {
2
AuthSessionId,
3
- AuthAdministrativeScopes,
3
AuthStandardClientScopes,
4
AuthEnvironmentScopes,
5
type AuthClientMetadata,
@@ -508,7 +507,7 @@ export const make = Effect.gen(function* () {
507
.createIfAbsent({
508
sessionId: devAuth.sessionId,
509
subject: "reusable-dev-token",
511
- scopes: AuthAdministrativeScopes,
510
+ scopes: AuthStandardClientScopes,
511
method: "browser-session-cookie",
512
client: {
513
label: "Reusable dev token",
apps/server/src/cli/auth.ts
+2
-6
@@ -1,8 +1,4 @@
1
-import {
2
- AuthAdministrativeScopes,
3
- AuthSessionId,
4
- AuthStandardClientScopes,
5
-} from "@t3tools/contracts";
1
+import { AuthSessionId, AuthStandardClientScopes } from "@t3tools/contracts";
2
import * as Console from "effect/Console";
3
import * as Effect from "effect/Effect";
4
import * as Layer from "effect/Layer";
@@ -163,7 +159,7 @@ const pairingCommand = Command.make("pairing").pipe(
159
160
const sessionIssueCommand = Command.make("issue", {
161
...authLocationFlags,
166
- scopes: authScopesFlag(AuthAdministrativeScopes),
162
+ scopes: authScopesFlag(AuthStandardClientScopes),
163
ttl: ttlFlag,
164
label: labelFlag,
165
subject: subjectFlag,
apps/server/src/cli/project.ts
+2
-2
@@ -1,5 +1,5 @@
1
import {
2
- AuthAdministrativeScopes,
2
+ AuthStandardClientScopes,
3
CommandId,
4
EnvironmentHttpApi,
5
EnvironmentHttpCommonError,
@@ -221,7 +221,7 @@ const withProjectCliSessionToken = <A, E, R>(
221
) =>
222
Effect.acquireUseRelease(
223
environmentAuth.issueSession({
224
- scopes: AuthAdministrativeScopes,
224
+ scopes: AuthStandardClientScopes,
225
label: "t3 project cli",
226
}),
227
(issued) => run(issued.token),
apps/web/src/components/cloud/ConnectOnboardingDialog.tsx
+1
-6
@@ -1,11 +1,6 @@
1
import { useAuth } from "@clerk/react";
2
import { useAtomValue } from "@effect/atom-react";
3
-import {
4
- AuthAdministrativeScopes,
5
- AuthRelayReadScope,
6
- AuthRelayWriteScope,
7
- type AuthSessionState,
8
-} from "@t3tools/contracts";
3
+import { AuthRelayReadScope, AuthRelayWriteScope, type AuthSessionState } from "@t3tools/contracts";
4
import { AsyncResult, Atom } from "effect/reactivity";
5
import { useEffect, useRef, useState } from "react";
6
docs/internals/environment-auth.md
+7
-3
@@ -7,9 +7,13 @@ identity and relay credentials belong to a separate trust boundary, described in
7
## Authority survives transport changes
8
9
Pairing delegates a set of scopes. Exchanging a bootstrap credential can narrow
10
-that grant but cannot widen it. Ordinary pairing does not grant access-management
11
-or relay-management authority. Creating another pairing link requires both
12
-`access:write` and every scope being delegated. The
10
+that grant but cannot widen it. The default grant includes access and relay
11
+management: `terminal:operate` is a shell as the server's user and
12
+`orchestration:operate` can start a full-access agent, and either can mint a
13
+session with every scope through `t3 auth session issue`, so withholding
14
+management from the default would not be a boundary. A narrower client gets
15
+explicit scopes. Creating another pairing link requires both `access:write` and
16
+every scope being delegated. The
17
[auth handlers](../../apps/server/src/auth/http.ts) enforce this at issuance;
18
client labels and device metadata have no authorization role.
19
docs/user/outside-agents.md
+2
-2
@@ -38,8 +38,8 @@ The page names the agent and where its access goes:
38
39
Only approve a sign-in you just started. To approve, enter a pairing code from
40
**Settings → Connections** or from `t3 auth pairing create` on the host. A
41
-browser already signed in to the environment as an administrator can approve
42
-without a code.
41
+browser already signed in to the environment with permission to manage access
42
+can approve without a code.
43
44
Then choose what the agent may do:
45
docs/user/remote-access.md
+12
-9
@@ -255,9 +255,11 @@ npx t3 pair --scope orchestration:read --scope relay:read
255
256
The selected scopes replace the default permissions. The same option works with
257
`npx t3 auth pairing create` and `npx t3 auth session issue`; each command's
258
-`--help` lists the available scopes. Without `--scope`, pairing tokens retain
259
-standard client permissions and issued bearer sessions retain administrative
260
-permissions.
258
+`--help` lists the available scopes. Without `--scope`, pairing tokens and issued
259
+bearer sessions get every permission, including managing access and T3 Connect.
260
+A terminal or a full-access agent on the host can reach those as well, so a
261
+client that should not manage access also needs to go without `terminal:operate`
262
+and `orchestration:operate`.
263
264
To change an existing client's permissions, create a fresh pairing link with the
265
scopes it needs. In a browser opened directly on the environment, open that link
@@ -276,12 +278,13 @@ worktrees. It does not restrict what a task does. Starting a task in a new
278
worktree still creates that branch and worktree with `orchestration:operate`,
279
and the agent it runs can use Git however the environment allows.
280
279
-Settings changes, provider management, and environment maintenance can be granted
280
-separately from access administration. New standard pairings include these
281
-permissions. Existing clients can stay connected after an update, but newly separated
282
-features may require pairing again with the permissions they need. Older clients
283
-may show controls that the server denies. Create a fresh pairing link to change
284
-a client's permissions.
281
+Settings changes, provider management, environment maintenance, access
282
+management, and T3 Connect management can each be granted separately. New
283
+pairings without `--scope` include all of them. Existing clients keep the
284
+permissions they paired with and can stay connected after an update, but newly
285
+separated features may require pairing again with the permissions they need.
286
+Older clients may show controls that the server denies. Create a fresh pairing
287
+link to change a client's permissions.
288
289
`filesystem:read` allows browsing host files, opening workspace files, and viewing
290
local changes. Add `filesystem:write` to allow editing files or saving plans to
packages/client-runtime/src/authorization/layer.test.ts
+2
-6
@@ -1,8 +1,4 @@
1
-import {
2
- AuthAdministrativeScopes,
3
- AuthStandardClientScopes,
4
- EnvironmentId,
5
-} from "@t3tools/contracts";
1
+import { AuthStandardClientScopes, EnvironmentId } from "@t3tools/contracts";
2
import {
3
RelayEnvironmentConnectScope,
4
type RelayEnvironmentConnectResponse,
@@ -496,7 +492,7 @@ describe("RemoteEnvironmentAuthorization", () => {
492
493
it.effect.each([
494
{ name: "read-only", grantScopes: ["orchestration:read"] },
499
- { name: "administrative", grantScopes: AuthAdministrativeScopes },
495
+ { name: "default", grantScopes: AuthStandardClientScopes },
496
] as const)(
497
"inherits $name pairing grant scopes for websocket authorization and HTTP renewal",
498
({ grantScopes }) =>
packages/client-runtime/src/connection/onboarding.test.ts
+1
-2
@@ -1,5 +1,4 @@
1
import {
2
- AuthAdministrativeScopes,
2
AuthStandardClientScopes,
3
EnvironmentId,
4
type AuthEnvironmentScope,
@@ -423,7 +422,7 @@ describe("connection onboarding", () => {
422
);
423
it.effect.each([
424
{ label: "read-only", scopes: ["orchestration:read"] },
426
- { label: "administrative", scopes: AuthAdministrativeScopes },
425
+ { label: "default", scopes: AuthStandardClientScopes },
426
] as const)("preserves the $label grant when pairing a remote environment", ({ scopes }) =>
427
Effect.gen(function* () {
428
const calls: Array<{ readonly url: string; readonly init: RequestInit }> = [];
packages/contracts/src/auth.ts
+3
-3
@@ -146,6 +146,9 @@ export function sessionHasLegacyPermissions(session: SessionGrantInput): boolean
146
);
147
}
148
149
+// Access and relay management are included because terminal:operate and
150
+// orchestration:operate already reach that authority through a shell or a
151
+// full-access agent. Narrowing a grant means choosing explicit scopes.
152
export const AuthStandardClientScopes = [
153
AuthOrchestrationReadScope,
154
AuthOrchestrationOperateScope,
@@ -160,9 +163,6 @@ export const AuthStandardClientScopes = [
163
AuthFilesystemReadScope,
164
AuthFilesystemWriteScope,
165
AuthRelayReadScope,
163
-] as const;
164
-export const AuthAdministrativeScopes = [
165
- ...AuthStandardClientScopes,
166
AuthAccessReadScope,
167
AuthAccessWriteScope,
168
AuthRelayWriteScope,