Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

Adds github-authentication.allowedOrganizations setting to restrict GitHub sign-ins to members of specified organizations. Enables policy enforcement for managed environments.

Changes

Configuration

  • Added github-authentication.allowedOrganizations: string[] setting (defaults to [] for backward compatibility)
  • Localized description in package.nls.json

Validation Logic

  • GitHubServer.checkOrganizationMembership() - Queries /user/orgs API endpoint, case-insensitive matching, returns true if user belongs to any configured org
  • createSession() - Validates during sign-in, blocks with error message if non-compliant
  • readSessions() - Validates existing sessions on startup, removes non-compliant sessions silently

Telemetry

  • organizationValidationSuccess / organizationValidationFailed events with allowedOrganizationsCount metric

Example

{
  "github-authentication.allowedOrganizations": ["microsoft", "github"]
}

User attempting sign-in must be member of microsoft OR github organization. Existing sessions not meeting requirements are removed on VS Code reload.

Testing

See /tmp/TESTING_GUIDE.md for comprehensive test scenarios covering default behavior, member/non-member cases, multiple organizations, GHES support, and session cleanup.

Original prompt

Add a new setting in the github authentication extension that enforces all github users signed in are a member of one of the organizations present in the setting. We will then define policy to enforce this

The user has attached the following file paths as relevant context:

  • .github/instructions/learnings.instructions.md
  • .github/copilot-instructions.md
  • AGENTS.md

Created from VS Code.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 9, 2025 00:01
- Add github-authentication.allowedOrganizations setting
- Implement checkOrganizationMembership in GitHubServer
- Validate organization membership during session creation
- Validate organization membership for existing sessions
- Add telemetry for organization validation events

Co-authored-by: joshspicer <[email protected]>
Avoid logging specific organization names or user memberships to prevent exposing sensitive information in logs

Co-authored-by: joshspicer <[email protected]>
Use safer error message extraction to handle non-Error exceptions

Co-authored-by: joshspicer <[email protected]>
Copilot AI changed the title [WIP] Add enforcement setting for GitHub organization membership Add organization membership enforcement setting for GitHub authentication Dec 9, 2025
Copilot AI requested a review from joshspicer December 9, 2025 00:16
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