MCPcopy Index your code
hub / github.com/coder/coder / workspaceChecks

Function workspaceChecks

site/src/modules/workspaces/permissions.ts:3–45  ·  view source on GitHub ↗
(workspace: Workspace)

Source from the content-addressed store, hash-verified

1import type { AuthorizationCheck, Workspace } from "#/api/typesGenerated";
2
3export const workspaceChecks = (workspace: Workspace) =>
4 ({
5 readWorkspace: {
6 object: {
7 resource_type: "workspace",
8 resource_id: workspace.id,
9 owner_id: workspace.owner_id,
10 },
11 action: "read",
12 },
13 shareWorkspace: {
14 object: {
15 resource_type: "workspace",
16 resource_id: workspace.id,
17 owner_id: workspace.owner_id,
18 },
19 action: "share",
20 },
21 updateWorkspace: {
22 object: {
23 resource_type: "workspace",
24 resource_id: workspace.id,
25 owner_id: workspace.owner_id,
26 },
27 action: "update",
28 },
29 updateWorkspaceVersion: {
30 object: {
31 resource_type: "template",
32 resource_id: workspace.template_id,
33 },
34 action: "update",
35 },
36 // We only want to allow template admins to delete failed workspaces since
37 // they can leave orphaned resources.
38 deleteFailedWorkspace: {
39 object: {
40 resource_type: "template",
41 resource_id: workspace.template_id,
42 },
43 action: "update",
44 },
45 }) satisfies Record<string, AuthorizationCheck>;
46
47export type WorkspacePermissions = Record<
48 keyof ReturnType<typeof workspaceChecks>,

Callers 4

WorkspaceSharingPageFunction · 0.90
WorkspaceParametersPageFunction · 0.90
workspacePermissionsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected