Skip to content

Add AllowedGitHubOrganizations policy to gate chat features by org membership#302981

Draft
joshspicer wants to merge 1 commit intomainfrom
jospicer/github-org-policy
Draft

Add AllowedGitHubOrganizations policy to gate chat features by org membership#302981
joshspicer wants to merge 1 commit intomainfrom
jospicer/github-org-policy

Conversation

@joshspicer
Copy link
Member

Summary

Introduces a hidden, policy-backed setting chat.allowedGitHubOrganizations that allows enterprise IT admins to restrict policy-gated chat features (such as MCP) to users who are members of specified GitHub organizations.

Refs: https://github.com/microsoft/vscode-internalbacklog/issues/6435

Setting

  • Config key: chat.allowedGitHubOrganizations
  • Type: string (comma-separated org login names, e.g. "microsoft,github")
  • Hidden: included: false — not visible in Settings UI, only set via MDM policy
  • Policy: AllowedGitHubOrganizations, category InteractiveSession, OS-level MDM delivery

Gate Logic

When chat.allowedGitHubOrganizations is configured (via MDM policy):

  • Features are blocked by default until the user's org membership is confirmed
  • The user's resolved organization_login_list from entitlements is compared against the allowed orgs list
  • If the user is not a member of any allowed org, features remain blocked
  • If the setting is empty/unset, no restriction applies (passthrough behavior)

The gate logic lives in ChatEntitlementContext.computeOrgPolicySatisfied() and re-evaluates whenever:

  • Entitlement data changes (user signs in/out, orgs resolve)
  • The chat.allowedGitHubOrganizations configuration changes

How Features Opt In

Context key (declarative, for UI)

when: chatGitHubOrgPolicySatisfied

Service property (programmatic)

chatEntitlementService.orgPolicySatisfied // boolean

Observable (reactive)

observableFromEvent(
  chatEntitlementService.onDidChangeEntitlement,
  () => chatEntitlementService.orgPolicySatisfied
)

MCP Integration (first consumer)

MCP features check the org gate at three levels:

  • McpRegistry.collections — returns empty when gate not satisfied
  • McpDiscovery — skips server discovery when gate not satisfied
  • McpWorkbenchService.getEnablementStatus() — shows disabled status with org policy message

Files Changed

File Change
chat/common/constants.ts New AllowedGitHubOrganizations config key
chat/browser/chat.contribution.ts Setting registration with policy
chat/common/chatEntitlementService.ts Gate logic, context key, orgPolicySatisfied property
chat/common/actions/chatContextKeys.ts Re-export context key
mcp/common/mcpRegistry.ts Gate MCP collections + lazy state
mcp/browser/mcpDiscovery.ts Gate MCP discovery
mcp/browser/mcpWorkbenchService.ts Gate MCP enablement status
build/lib/policies/policyData.jsonc Exported policy artifact
Test mocks Added orgPolicySatisfied = true

…mbership

Introduces a hidden, policy-backed setting `chat.allowedGitHubOrganizations`
that allows enterprise IT admins to restrict policy-gated chat features
(such as MCP) to users who are members of specified GitHub organizations.

The setting is a comma-separated list of org login names, delivered via
OS-level MDM policy (`AllowedGitHubOrganizations`). When set:
- Features are blocked by default until the user's org membership is confirmed
- If the user is not a member of any allowed org, features remain blocked
- If the setting is empty/unset, no restriction applies (passthrough)

Implementation:
- New config key `chat.allowedGitHubOrganizations` with `included: false`
  and `AllowedGitHubOrganizations` policy (InteractiveSession category)
- Org gate logic in ChatEntitlementContext compares allowed orgs setting
  against the user's resolved organizations from entitlements
- New context key `chatGitHubOrgPolicySatisfied` for declarative UI gating
- New `orgPolicySatisfied` property on IChatEntitlementService for code gating
- MCP integration: McpRegistry, McpDiscovery, and McpWorkbenchService all
  check the org gate alongside existing McpAccessValue checks

Other features can opt in by checking the context key in when clauses
or reading chatEntitlementService.orgPolicySatisfied.

Refs: microsoft/vscode-internalbacklog#6435

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 18, 2026 20:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new enterprise policy-backed configuration (chat.allowedGitHubOrganizations) that gates policy-controlled chat features (initially MCP) based on the signed-in user’s GitHub organization membership, exposing the result via a new entitlement context key and service property.

Changes:

  • Introduces the hidden, policy-backed setting chat.allowedGitHubOrganizations and exports it into policy artifacts.
  • Computes and publishes org-policy satisfaction via ChatEntitlementContext / chatGitHubOrgPolicySatisfied and IChatEntitlementService.orgPolicySatisfied.
  • Gates MCP registry collections, discovery, and enablement status when the org policy is not satisfied; updates test mocks for the new interface member.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/vs/workbench/test/common/workbenchTestServices.ts Updates test entitlement service mock to implement orgPolicySatisfied.
src/vs/workbench/services/chat/common/chatEntitlementService.ts Adds org-policy context key + orgPolicySatisfied, and computes satisfaction from config + entitlements.
src/vs/workbench/contrib/mcp/common/mcpRegistry.ts Filters MCP collections/lazy state when org policy gate is not satisfied.
src/vs/workbench/contrib/mcp/browser/mcpWorkbenchService.ts Surfaces MCP disabled status/message when org policy gate is not satisfied.
src/vs/workbench/contrib/mcp/browser/mcpDiscovery.ts Skips MCP discovery when org policy gate is not satisfied.
src/vs/workbench/contrib/chat/common/constants.ts Adds ChatConfiguration.AllowedGitHubOrganizations constant.
src/vs/workbench/contrib/chat/common/actions/chatContextKeys.ts Re-exports the new entitlement context key for declarative gating (when).
src/vs/workbench/contrib/chat/browser/chat.contribution.ts Registers the hidden setting and associates it with the AllowedGitHubOrganizations policy.
src/vs/sessions/test/web.test.ts Updates Sessions window mock entitlement service to implement orgPolicySatisfied.
build/lib/policies/policyData.jsonc Adds the new policy entry to the exported policy data artifact.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +791 to +795
return {
state: McpServerEnablementState.DisabledByAccess,
message: {
severity: Severity.Warning,
text: new MarkdownString(localize('disabled - org policy', "This MCP server is disabled because the signed-in GitHub account is not a member of an allowed organization."))
}

get orgPolicySatisfied(): boolean {
return this.contextKeyService.getContextKeyValue<boolean>(ChatEntitlementContextKeys.githubOrgPolicySatisfied.key) !== false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants