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
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,13 @@ jobs:
- name: Validate config
run: npm run validate

- name: Test configuration
run: npm test

- name: Verify Workspace SSO GitHub IDs
env:
GH_TOKEN: ${{ github.token }}
run: npm run check-github-ids

- name: Check formatting
run: npm run format:check
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Infrastructure as Code for managing access to MCP community resources using Pulu
- **Google Workspace Groups**: Automatically syncs group memberships for @modelcontextprotocol.io email accounts
- **Email Groups**: Groups with `isEmailGroup: true` accept emails from anyone (including external users) and notify all members. External posts are moderated for security.
- **Google Workspace User Accounts**: Provisions @modelcontextprotocol.io accounts for members of roles with `provisionUser: true` (directly, or via a role nested under one through `github.parent` — e.g. SDK teams under `sdk-maintainers`, working groups under `working-groups`)
- **GitHub sign-in for Google Workspace**: Cloudflare Access is the SAML identity provider for Google Workspace, so allowlisted maintainers sign in to their `@modelcontextprotocol.io` account with GitHub. The allowlist and account mapping come from [`src/config/workspaceSso.ts`](src/config/workspaceSso.ts) and `users.ts`. See [GitHub sign-in for Google Workspace](#github-sign-in-for-google-workspace) below.
- **Discord**: Syncs the Discord roles declared in [`src/config/roles.ts`](src/config/roles.ts) to the members' Discord IDs in `users.ts`, and manages the settings of the channels declared in [`src/config/channels.ts`](src/config/channels.ts), including thread-only forum/media channels. See [Discord channels](#discord-channels) below.
- **Cloudflare Access (security-room)**: Syncs the Cloudflare Zero Trust Access policy that decides who can sign in to `securityroom.modelcontextprotocol.io` from the roles declared in [`src/config/accessPolicies.ts`](src/config/accessPolicies.ts). See [Cloudflare Access (security-room)](#cloudflare-access-security-room) below.
- **npm & PyPI Package Publishing Access** (declared, not applied): Expected registry access is declared in [`src/config/packageAccess.ts`](src/config/packageAccess.ts) and drift against the live npm registry is detected by CI — but changes are applied manually by a maintainer. See [npm & PyPI Package Publishing Access](#npm--pypi-package-publishing-access) below for why and how.
Expand Down Expand Up @@ -127,6 +128,16 @@ Channels listed in [`src/config/channels.ts`](src/config/channels.ts) are manage
- With `cloudflare:importExistingPolicies: "true"` in `Pulumi.prod.yaml`, the first deploy imports the existing `Maintainers` policy (by its `cloudflarePolicyId`) as-is, ignoring its rule lists.
- Then set the flag to `"false"` in a follow-up PR; its preview shows exactly the include-rule changes that the next deploy applies. Leave the flag off from then on.

## GitHub sign-in for Google Workspace

Cloudflare Access acts as the SAML identity provider for Google Workspace. The `workspace-sso` GitHub team's direct membership and the numeric GitHub ID → Workspace email mapping both come from `users.ts`. To enable someone, confirm their `githubUserId` and add `ROLE_IDS.WORKSPACE_SSO` in a reviewed PR. They also need a current Google provisioning role. CI verifies each enabled ID against the configured GitHub login.

Use a modern Google Workspace SAML profile and keep legacy SSO disabled. Configure the profile with the Cloudflare Access SSO URL, entity ID and signing certificate. Set `cloudflare:googleSamlEntityId` and `cloudflare:googleSamlAcsUrl` together using the values from that profile. With both values unset, the app uses placeholders under the reserved `.invalid` domain. The Access edit token can change which Workspace identity Cloudflare signs.

For accounts assigned to the profile, confirm that post-SSO verification applies, 2-Step Verification is enforced, and each user is enrolled. Keep Workspace admin accounts outside the assigned organizational unit.

**Offboarding:** suspend the Workspace account, reset its sign-in cookies and revoke OAuth grants and app passwords as applicable. Revoke the user's Cloudflare Access sessions, remove the Workspace SSO role in `users.ts`, and deploy. The Access app and policy each use one hour. Cloudflare can reuse stored GitHub membership until the global session expires (check the tenant setting), and Google manages its own sessions.

## npm & PyPI Package Publishing Access

Publishing access to the `modelcontextprotocol` npm organization and to the MCP PyPI projects is **config-as-code with human-applied changes** — deliberately outside the Pulumi resource graph:
Expand Down Expand Up @@ -233,7 +244,7 @@ The following secrets must be configured in GitHub Actions for automated deploym
- Keep this secure - if lost, you cannot decrypt your Pulumi state

- **`CLOUDFLARE_ROLE_MANAGEMENT_TOKEN`** (optional, `production` and `preview` environments): Cloudflare token dedicated to Access policy role management, scoped only to **Account → Access: Apps and Policies → Edit** on the MCP Domain Account (not a general-purpose API token)
- Used to manage the Cloudflare Access policy for `securityroom.modelcontextprotocol.io` (see [Cloudflare Access (security-room)](#cloudflare-access-security-room))
- Used to manage the Cloudflare Access policy for `securityroom.modelcontextprotocol.io` (see [Cloudflare Access (security-room)](#cloudflare-access-security-room)) and the Google Workspace sign-in application (see [GitHub sign-in for Google Workspace](#github-sign-in-for-google-workspace))
Comment thread
sambhav marked this conversation as resolved.
Resolved

## Initial Setup

Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"build": "tsc",
"validate": "npx ts-node scripts/validate-config.ts",
"test": "npx ts-node scripts/test-config.ts",
"test": "npx ts-node scripts/test-config.ts && npx ts-node scripts/test-workspace-sso.ts",
"check-github-ids": "npx ts-node scripts/check-github-ids.ts",
"check-package-drift": "npx ts-node scripts/check-package-drift.ts",
"check": "npm run format:check && npm run validate && npm run test",
"format": "prettier --write .",
Expand All @@ -22,6 +23,7 @@
},
"devDependencies": {
"@types/node": "^22.18.6",
"jsonata": "^2.2.1",
"prettier": "^3.7.2",
"ts-node": "^10.9.2",
"typescript": "^5.9.2"
Expand Down
21 changes: 21 additions & 0 deletions scripts/check-github-ids.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Live check (needs `gh` auth): each Workspace SSO member's numeric githubUserId
* resolves to their configured GitHub login, so a typo can't map someone else's
* GitHub account to a Workspace mailbox.
*/
import { execFileSync } from 'node:child_process';
import { ROLE_IDS } from '../src/config/roleIds';
import { MEMBERS } from '../src/config/users';

let failed = false;
for (const m of MEMBERS.filter((member) => member.memberOf.includes(ROLE_IDS.WORKSPACE_SSO))) {
const login = execFileSync('gh', ['api', `/user/${m.githubUserId}`, '--jq', '.login'], {
encoding: 'utf8',
}).trim();
if (login.toLowerCase() !== m.github?.toLowerCase()) {
console.error(`ERROR: GitHub user ID ${m.githubUserId} resolves to ${login}, not ${m.github}`);
failed = true;
}
}
if (failed) process.exit(1);
console.log('All Workspace SSO GitHub IDs match their logins.');
87 changes: 87 additions & 0 deletions scripts/test-workspace-sso.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import assert from 'node:assert/strict';
import { test } from 'node:test';
import jsonata from 'jsonata';
import { ROLE_IDS } from '../src/config/roleIds';
import type { Member } from '../src/config/utils';
import {
buildNameIdTransform,
getWorkspaceSsoTable,
googleSamlProfile,
SAML_ATTRIBUTE_TRANSFORM,
UNMAPPED_NAME_ID,
} from '../src/config/workspaceSso';

const pilot: Member = {
github: 'octo',
githubUserId: 42,
firstName: 'Octo',
lastName: 'Cat',
googleEmailPrefix: 'octo',
memberOf: [ROLE_IDS.WORKSPACE_SSO, ROLE_IDS.GO_SDK],
};
const email = 'octo@modelcontextprotocol.io';
// Shape of the input Cloudflare passes to the NameID transform, captured from a live assertion.
const identity = {
id: 42,
name: 'Octo Cat',
email: 'octo@example.com',
groups: [{ id: 1, name: 'modelcontextprotocol', teams: [{ name: 'maintainers' }] }],
};

test('the pilot team requires a GitHub identity and a current provisioning role', () => {
assert.deepEqual(getWorkspaceSsoTable([pilot, { ...pilot, memberOf: [] }]), { 42: email });
for (const change of [
{ github: undefined },
{ githubUserId: undefined },
{ githubUserId: -1 },
{ googleEmailPrefix: 'x@evil.com' },
{ googleEmailPrefix: undefined },
{ firstName: undefined },
{ existingGWSUser: true, memberOf: [ROLE_IDS.WORKSPACE_SSO] },
{ skipGoogleUserProvisioning: true },
])
assert.throws(() => getWorkspaceSsoTable([{ ...pilot, ...change }]));
assert.throws(() => getWorkspaceSsoTable([pilot, { ...pilot, googleEmailPrefix: 'cat' }]));
});

test('NameID uses the numeric ID and org', async () => {
const transform = jsonata(buildNameIdTransform({ 42: email }));
for (const id of [42, '42']) assert.equal(await transform.evaluate({ ...identity, id }), email);
for (const change of [
{ id: 43 },
{ id: undefined },
{ id: [42] },
{ id: '__proto__' },
{ groups: undefined },
{ groups: [{ name: 'other' }] },
])
assert.equal(await transform.evaluate({ ...identity, ...change }), UNMAPPED_NAME_ID);
assert.equal(await jsonata(buildNameIdTransform({})).evaluate(identity), UNMAPPED_NAME_ID);
});

test('Google requires both profile values after inert bootstrap', () => {
const issuer = 'https://accounts.google.com/samlrp/metadata?rpid=example';
const acs = 'https://accounts.google.com/samlrp/example/acs';
assert.deepEqual(googleSamlProfile(), {
spEntityId: 'https://access.invalid/sp',
consumerServiceUrl: 'https://access.invalid/acs',
});
assert.deepEqual(googleSamlProfile(issuer, acs), { spEntityId: issuer, consumerServiceUrl: acs });
for (const id of [undefined, '', 'google.com', 'google.com/a/example.org'])
assert.throws(() => googleSamlProfile(id, acs));
for (const url of [
undefined,
'https://accounts.google.com/a/example.org/acs',
'https://www.google.com/a/example.org/acs',
])
assert.throws(() => googleSamlProfile(issuer, url));
});

test('the attribute transform sends one constant attribute', async () => {
assert.deepEqual(
{ ...(await jsonata(SAML_ATTRIBUTE_TRANSFORM).evaluate(identity)) },
{
source: 'cloudflare-access',
}
);
});
9 changes: 9 additions & 0 deletions scripts/validate-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { DISCORD_CHANNELS, validateDiscordChannels } from '../src/config/channel
import { getDiscordRolePermissionErrors } from '../src/config/discordPermissions';
import { hasProvisionUserRole, resolveGoogleMemberEmail } from '../src/config/utils';
import type { RoleId } from '../src/config/roleIds';
import { getWorkspaceSsoTable } from '../src/config/workspaceSso';

const roleLookup = buildRoleLookup();

Expand Down Expand Up @@ -445,6 +446,14 @@ for (const role of ROLES) {
}
}

console.log('Validating Workspace SSO members...');
try {
getWorkspaceSsoTable();
} catch (e) {
console.error(`ERROR: ${(e as Error).message}`);
hasErrors = true;
}

if (hasErrors) {
console.error('\nValidation failed! Please fix the errors above.');
process.exit(1);
Expand Down
56 changes: 56 additions & 0 deletions src/cloudflare.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import * as pulumi from '@pulumi/pulumi';
import * as cloudflare from '@pulumi/cloudflare';
import { ACCESS_POLICIES, GITHUB_ORG, getAccessPolicyTeams } from './config/accessPolicies';
import { githubTeams } from './github';
import { ROLE_IDS } from './config/roleIds';
import {
buildNameIdTransform,
getWorkspaceSsoTable,
googleSamlProfile,
SAML_ATTRIBUTE_TRANSFORM,
} from './config/workspaceSso';

const config = new pulumi.Config('cloudflare');
// Cloudflare integration is optional - only enabled if roleManagementToken is configured,
Expand Down Expand Up @@ -65,6 +73,54 @@ if (CLOUDFLARE_ENABLED) {
}
);
});

// GitHub sign-in for Google Workspace: Access is the SAML IdP for Google's SSO
// profile. Workspace SSO team only, GitHub only; the NameID transform picks the account.
const workspaceSsoPolicy = new cloudflare.ZeroTrustAccessPolicy(
'access-policy-workspace-sso',
{
accountId,
name: 'Google Workspace sign-in',
decision: 'allow',
sessionDuration: '1h',
includes: [
{
githubOrganization: {
identityProviderId: githubIdentityProviderId,
name: GITHUB_ORG,
team: githubTeams[ROLE_IDS.WORKSPACE_SSO].slug,
},
},
],
// allowedIdps only limits which providers the login page offers; require the
// session itself to come from GitHub (e.g. not a one-time PIN from another app).
requires: [{ loginMethod: { id: githubIdentityProviderId } }],
},
{ provider, ignoreChanges: ['connectionRules'] }
);
new cloudflare.ZeroTrustAccessApplication(
'access-app-workspace-sso',
{
accountId,
name: 'Google Workspace',
type: 'saas',
allowedIdps: [githubIdentityProviderId],
allowAuthenticateViaWarp: false,
autoRedirectToIdentity: true,
appLauncherVisible: false,
sessionDuration: '1h',
policies: [{ id: workspaceSsoPolicy.id, precedence: 1 }],
saasApp: {
authType: 'saml',
...googleSamlProfile(config.get('googleSamlEntityId'), config.get('googleSamlAcsUrl')),
nameIdFormat: 'email',
samlAttributeTransformJsonata: SAML_ATTRIBUTE_TRANSFORM,
// The policy's login-method rule enforces GitHub; the transform input has no IdP field.
nameIdTransformJsonata: buildNameIdTransform(getWorkspaceSsoTable()),
},
Comment thread
sambhav marked this conversation as resolved.
Resolved
},
{ provider }
);
}

export const cloudflareAccessPolicyIds = Object.fromEntries(
Expand Down
1 change: 1 addition & 0 deletions src/config/roleIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const ROLE_IDS = {
MODERATORS: 'moderators',
SECURITY_MANAGERS: 'security-managers', // GitHub (org security_manager role) and the security@ email group
SECURITY_TEAM: 'security-team', // GitHub only (MCP Security Team; Cloudflare Access to securityroom.modelcontextprotocol.io)
WORKSPACE_SSO: 'workspace-sso',
ADMINISTRATORS: 'administrators', // Discord only
COMMUNITY_MANAGERS: 'community-managers', // Discord only
RELEASE_MANAGERS: 'release-managers', // Discord only
Expand Down
5 changes: 5 additions & 0 deletions src/config/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ export const ROLES: readonly Role[] = [
github: { team: 'steering-committee' },
// No discord - this is a GitHub-only organizational container
},
{
id: ROLE_IDS.WORKSPACE_SSO,
description: 'Members enabled for Google Workspace SAML sign-in',
github: { team: ROLE_IDS.WORKSPACE_SSO },
},
{
id: ROLE_IDS.ADMINISTRATORS,
description: 'Discord server administrators',
Expand Down
2 changes: 2 additions & 0 deletions src/config/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -980,12 +980,14 @@ export const MEMBERS: readonly Member[] = [
},
{
github: 'sambhav',
githubUserId: 16130816,
email: 'sambhavs.email@gmail.com',
firstName: 'Sambhav',
lastName: 'Kothari',
googleEmailPrefix: 'sambhav',
discord: '840109459212206090',
memberOf: [
ROLE_IDS.WORKSPACE_SSO,
ROLE_IDS.MAINTAINERS,
ROLE_IDS.FILESYSTEMS_WG,
ROLE_IDS.FILESYSTEMS_WG_LEADS,
Expand Down
16 changes: 16 additions & 0 deletions src/config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import type { Role } from './roles';
export interface Member {
/** GitHub username */
github?: string;
/** Numeric GitHub user ID, confirmed with the member (required for the workspace-sso team) */
githubUserId?: number;
/** Email address (for Google Workspace) */
email?: string;
/** Discord user ID (snowflake) */
Expand Down Expand Up @@ -54,6 +56,20 @@ export function resolveGoogleMemberEmail(member: Member): string | undefined {
: member.email;
}

/**
* Whether src/google.ts provisions (or, for existingGWSUser, would provision) a
* Google Workspace account for this member.
*/
export function isProvisionedGoogleUser(member: Member, roleLookup: Map<RoleId, Role>): boolean {
return (
!!member.firstName &&
!!member.lastName &&
!!member.googleEmailPrefix &&
!member.skipGoogleUserProvisioning &&
hasProvisionUserRole(member.memberOf, roleLookup)
);
}

/**
* Whether a member with the given roles is eligible for a Google Workspace
* user account. A member qualifies when any of their roles — or any role
Expand Down
Loading
Loading