Skip to content
Open
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
2 changes: 0 additions & 2 deletions apps/server/src/auth/RpcAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
AuthProvidersManageScope,
AuthEnvironmentMaintainScope,
AuthFilesystemReadScope,
AuthFilesystemWriteScope,
AuthDiagnosticsReadScope,
AuthOrchestrationOperateScope,
AuthOrchestrationReadScope,
Expand Down Expand Up @@ -151,7 +150,6 @@ export const RPC_REQUIRED_SCOPES = {
[WS_METHODS.projectsReadFile]: AuthFilesystemReadScope,
[WS_METHODS.projectsSearchContents]: AuthFilesystemReadScope,
[WS_METHODS.projectsSearchEntries]: AuthFilesystemReadScope,
[WS_METHODS.projectsWriteFile]: AuthFilesystemWriteScope,
[WS_METHODS.projectsEnsureScratch]: AuthOrchestrationOperateScope,
[WS_METHODS.projectsCreateNew]: AuthOrchestrationOperateScope,
[WS_METHODS.shellOpenInEditor]: AuthOrchestrationOperateScope,
Expand Down
22 changes: 22 additions & 0 deletions packages/client-runtime/src/state/commandPermissions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { vi } from "vite-plus/test";
import {
AuthAccessReadScope,
AuthAccessWriteScope,
AuthFilesystemWriteScope,
AuthOrchestrationOperateScope,
AuthOrchestrationReadScope,
AuthPreviewOperateScope,
Expand Down Expand Up @@ -131,6 +132,27 @@ describe("command permissions", () => {
),
);

it.effect("requires the destination filesystem write grant to write a file", () =>
Effect.scoped(
Effect.gen(function* () {
const registry = yield* setup;
const write = createCommandPermissions(runtime, WS_METHODS.projectsWriteFile);
registry.set(sessions(env), AsyncResult.success(grant(true)));
expect(registry.get(write.permissionAtom(env))).toBe(false);
registry.set(
sessions(env),
AsyncResult.success({
...grant(false),
scopes: [AuthFilesystemWriteScope],
permissions: [AuthFilesystemWriteScope],
}),
);
expect(registry.get(write.permissionAtom(env))).toBe(true);
yield* write.authorize(registry, env);
}),
),
);

it.effect("requires the destination provider grant to remove an incomplete connection", () =>
Effect.scoped(
Effect.gen(function* () {
Expand Down
1 change: 1 addition & 0 deletions packages/client-runtime/src/state/projectCommands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const makeHarness = Effect.fn("TestProjectCommands.makeHarness")(function* () {
});
const registry = AtomRegistry.make();
yield* Effect.addFinalizer(() => Effect.sync(() => registry.dispose()));
registry.mount(sessions(ENVIRONMENT_ID));
registry.set(
sessions(ENVIRONMENT_ID),
AsyncResult.success({
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/src/clientRpcPermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as Schema from "effect/Schema";
import { GitPreparePullRequestThreadInput, GitRunStackedActionInput } from "./git.ts";
import {
AuthAccessWriteScope,
AuthFilesystemWriteScope,
AuthOrchestrationOperateScope,
AuthOrchestrationReadScope,
AuthPreviewOperateScope,
Expand Down Expand Up @@ -36,6 +37,7 @@ export const CLIENT_GUARDED_RPC_SCOPES = {
[WS_METHODS.pullRequestsSetLabels]: AuthSourceControlWriteScope,
// Writing a guide runs a model on this environment's providers, which reading one does not.
[WS_METHODS.pullRequestsGenerateReviewGuide]: AuthOrchestrationOperateScope,
[WS_METHODS.projectsWriteFile]: AuthFilesystemWriteScope,
[WS_METHODS.projectsCreateFromThread]: AuthOrchestrationOperateScope,
[WS_METHODS.sourceControlCloneRepository]: AuthSourceControlWriteScope,
[WS_METHODS.sourceControlPublishRepository]: AuthSourceControlWriteScope,
Expand Down
Loading