mirror of
https://github.com/coder/coder.git
synced 2026-11-03 05:55:24 +08:00
Adds group and user ACLs to org-scoped MCP server configs so
organizations can restrict specific MCP servers to subsets of members,
mirroring the template ACL pattern.
## Summary
- Migration adds `group_acl`/`user_acl` JSONB columns (nested `{"<id>":
{"permissions": [...]}}` shape) and seeds every existing config with its
organization's Everyone group read entry (the Everyone group ID equals
the org ID), so member access is unchanged by default. Creation seeds
the same entry.
- The blanket org-member read grant from the base PR is replaced by ACL
evaluation: Rego requires org membership for every ACL grant, and
`GetAuthorizedMCPServerConfigs` compiles ACL-aware SQL filters.
- New `ActionShare` (org admins) gates `GET|PATCH
/api/experimental/organizations/{organization}/mcp-servers/{mcpserverconfig}/acl`
(nested under the organization like the rest of the config surface).
PATCH validates principals against the config's organization, merges
sparse updates under a row lock, stamps `updated_by`/`updated_at`, and
is audited as a Write with `Old` captured before authorization. A config
deleted concurrently between the middleware fetch and the locked
re-fetch is concealed as 404, matching the update and delete handlers.
ACL columns are tracked in the audit table.
- ACL management is available in all editions (no enterprise
entitlement), documented in the MCP servers page. Revoking an ACL does
not retro-strip already-selected configs from existing chats; new
selection is blocked at chat create.
- Force On respects the ACL: the forced set is loaded as the chat owner,
so a `force_on` server whose ACL denies the owner never attaches at
create, send, or generation time.
- No rolling-upgrade machinery: upgrades run in scheduled maintenance
downtime, so the migration only backfills existing rows; the API sets
the Everyone read grant explicitly on every insert.
Stacked on #27943. Part of the MCP org-separation stack.
Closes https://linear.app/codercom/issue/CODAGT-712
UAT: verified on a dogfood instance with two members and a custom group:
Everyone-seed default visibility, group grant with Everyone removal
(non-member loses list/fetch/selection), foreign-principal rejection,
non-admin share denial (audited 403 / concealed 404), user_acl restore,
and audited ACL diffs.
> Mux (AI agent) authored this PR on Mike's behalf.
<!-- mux-attribution: model=claude-fable-5 thinking=high -->
140 lines
9.4 KiB
Go
140 lines
9.4 KiB
Go
// Code generated by typegen/main.go. DO NOT EDIT.
|
|
package codersdk
|
|
|
|
type RBACResource string
|
|
|
|
const (
|
|
ResourceWildcard RBACResource = "*"
|
|
ResourceAIGatewayKey RBACResource = "ai_gateway_key"
|
|
ResourceAiModelPrice RBACResource = "ai_model_price"
|
|
ResourceAIProvider RBACResource = "ai_provider"
|
|
ResourceAiSeat RBACResource = "ai_seat"
|
|
ResourceAibridgeInterception RBACResource = "aibridge_interception"
|
|
ResourceApiKey RBACResource = "api_key"
|
|
ResourceAssignOrgRole RBACResource = "assign_org_role"
|
|
ResourceAssignRole RBACResource = "assign_role"
|
|
ResourceAuditLog RBACResource = "audit_log"
|
|
ResourceBoundaryLog RBACResource = "boundary_log"
|
|
ResourceBoundaryUsage RBACResource = "boundary_usage"
|
|
ResourceChat RBACResource = "chat"
|
|
ResourceConnectionLog RBACResource = "connection_log"
|
|
ResourceCryptoKey RBACResource = "crypto_key"
|
|
ResourceDebugInfo RBACResource = "debug_info"
|
|
ResourceDeploymentConfig RBACResource = "deployment_config"
|
|
ResourceDeploymentStats RBACResource = "deployment_stats"
|
|
ResourceFile RBACResource = "file"
|
|
ResourceGroup RBACResource = "group"
|
|
ResourceGroupMember RBACResource = "group_member"
|
|
ResourceIdpsyncSettings RBACResource = "idpsync_settings"
|
|
ResourceInboxNotification RBACResource = "inbox_notification"
|
|
ResourceLicense RBACResource = "license"
|
|
ResourceMCPServerConfig RBACResource = "mcp_server_config"
|
|
ResourceNotificationMessage RBACResource = "notification_message"
|
|
ResourceNotificationPreference RBACResource = "notification_preference"
|
|
ResourceNotificationTemplate RBACResource = "notification_template"
|
|
ResourceOauth2App RBACResource = "oauth2_app"
|
|
ResourceOauth2AppCodeToken RBACResource = "oauth2_app_code_token"
|
|
ResourceOauth2AppSecret RBACResource = "oauth2_app_secret"
|
|
ResourceOrganization RBACResource = "organization"
|
|
ResourceOrganizationMember RBACResource = "organization_member"
|
|
ResourcePrebuiltWorkspace RBACResource = "prebuilt_workspace"
|
|
ResourceProvisionerDaemon RBACResource = "provisioner_daemon"
|
|
ResourceProvisionerJobs RBACResource = "provisioner_jobs"
|
|
ResourceReplicas RBACResource = "replicas"
|
|
ResourceSystem RBACResource = "system"
|
|
ResourceTailnetCoordinator RBACResource = "tailnet_coordinator"
|
|
ResourceTask RBACResource = "task"
|
|
ResourceTemplate RBACResource = "template"
|
|
ResourceUsageEvent RBACResource = "usage_event"
|
|
ResourceUser RBACResource = "user"
|
|
ResourceUserSecret RBACResource = "user_secret"
|
|
ResourceUserSkill RBACResource = "user_skill"
|
|
ResourceWebpushSubscription RBACResource = "webpush_subscription"
|
|
ResourceWorkspace RBACResource = "workspace"
|
|
ResourceWorkspaceAgentDevcontainers RBACResource = "workspace_agent_devcontainers"
|
|
ResourceWorkspaceAgentResourceMonitor RBACResource = "workspace_agent_resource_monitor"
|
|
ResourceWorkspaceBuildOrchestration RBACResource = "workspace_build_orchestration"
|
|
ResourceWorkspaceDormant RBACResource = "workspace_dormant"
|
|
ResourceWorkspaceProxy RBACResource = "workspace_proxy"
|
|
)
|
|
|
|
type RBACAction string
|
|
|
|
const (
|
|
ActionApplicationConnect RBACAction = "application_connect"
|
|
ActionAssign RBACAction = "assign"
|
|
ActionCreate RBACAction = "create"
|
|
ActionCreateAgent RBACAction = "create_agent"
|
|
ActionDelete RBACAction = "delete"
|
|
ActionDeleteAgent RBACAction = "delete_agent"
|
|
ActionRead RBACAction = "read"
|
|
ActionReadPersonal RBACAction = "read_personal"
|
|
ActionSSH RBACAction = "ssh"
|
|
ActionShare RBACAction = "share"
|
|
ActionUnassign RBACAction = "unassign"
|
|
ActionUpdate RBACAction = "update"
|
|
ActionUpdateAgent RBACAction = "update_agent"
|
|
ActionUpdatePersonal RBACAction = "update_personal"
|
|
ActionUse RBACAction = "use"
|
|
ActionViewInsights RBACAction = "view_insights"
|
|
ActionWorkspaceStart RBACAction = "start"
|
|
ActionWorkspaceStop RBACAction = "stop"
|
|
)
|
|
|
|
// RBACResourceActions is the mapping of resources to which actions are valid for
|
|
// said resource type.
|
|
var RBACResourceActions = map[RBACResource][]RBACAction{
|
|
ResourceWildcard: {},
|
|
ResourceAIGatewayKey: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceAiModelPrice: {ActionRead, ActionUpdate},
|
|
ResourceAIProvider: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceAiSeat: {ActionCreate, ActionRead},
|
|
ResourceAibridgeInterception: {ActionCreate, ActionRead, ActionUpdate},
|
|
ResourceApiKey: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceAssignOrgRole: {ActionAssign, ActionCreate, ActionDelete, ActionRead, ActionUnassign, ActionUpdate},
|
|
ResourceAssignRole: {ActionAssign, ActionRead, ActionUnassign},
|
|
ResourceAuditLog: {ActionCreate, ActionRead},
|
|
ResourceBoundaryLog: {ActionCreate, ActionDelete, ActionRead},
|
|
ResourceBoundaryUsage: {ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceChat: {ActionCreate, ActionDelete, ActionRead, ActionShare, ActionUpdate},
|
|
ResourceConnectionLog: {ActionRead, ActionUpdate},
|
|
ResourceCryptoKey: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceDebugInfo: {ActionRead},
|
|
ResourceDeploymentConfig: {ActionRead, ActionUpdate},
|
|
ResourceDeploymentStats: {ActionRead},
|
|
ResourceFile: {ActionCreate, ActionRead},
|
|
ResourceGroup: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceGroupMember: {ActionRead},
|
|
ResourceIdpsyncSettings: {ActionRead, ActionUpdate},
|
|
ResourceInboxNotification: {ActionCreate, ActionRead, ActionUpdate},
|
|
ResourceLicense: {ActionCreate, ActionDelete, ActionRead},
|
|
ResourceMCPServerConfig: {ActionCreate, ActionDelete, ActionRead, ActionShare, ActionUpdate},
|
|
ResourceNotificationMessage: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceNotificationPreference: {ActionRead, ActionUpdate},
|
|
ResourceNotificationTemplate: {ActionRead, ActionUpdate},
|
|
ResourceOauth2App: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceOauth2AppCodeToken: {ActionCreate, ActionDelete, ActionRead},
|
|
ResourceOauth2AppSecret: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceOrganization: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceOrganizationMember: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourcePrebuiltWorkspace: {ActionDelete, ActionUpdate},
|
|
ResourceProvisionerDaemon: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceProvisionerJobs: {ActionCreate, ActionRead, ActionUpdate},
|
|
ResourceReplicas: {ActionRead},
|
|
ResourceSystem: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceTailnetCoordinator: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceTask: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceTemplate: {ActionCreate, ActionDelete, ActionRead, ActionUpdate, ActionUse, ActionViewInsights},
|
|
ResourceUsageEvent: {ActionCreate, ActionRead, ActionUpdate},
|
|
ResourceUser: {ActionCreate, ActionDelete, ActionRead, ActionReadPersonal, ActionUpdate, ActionUpdatePersonal},
|
|
ResourceUserSecret: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceUserSkill: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceWebpushSubscription: {ActionCreate, ActionDelete, ActionRead},
|
|
ResourceWorkspace: {ActionApplicationConnect, ActionCreate, ActionCreateAgent, ActionDelete, ActionDeleteAgent, ActionRead, ActionShare, ActionSSH, ActionWorkspaceStart, ActionWorkspaceStop, ActionUpdate, ActionUpdateAgent},
|
|
ResourceWorkspaceAgentDevcontainers: {ActionCreate},
|
|
ResourceWorkspaceAgentResourceMonitor: {ActionCreate, ActionRead, ActionUpdate},
|
|
ResourceWorkspaceBuildOrchestration: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
ResourceWorkspaceDormant: {ActionApplicationConnect, ActionCreate, ActionCreateAgent, ActionDelete, ActionDeleteAgent, ActionRead, ActionShare, ActionSSH, ActionWorkspaceStart, ActionWorkspaceStop, ActionUpdate, ActionUpdateAgent},
|
|
ResourceWorkspaceProxy: {ActionCreate, ActionDelete, ActionRead, ActionUpdate},
|
|
}
|