Skip to content

Gate enterprise-managed authorization behind a PostHog flag - #1740

Closed
RhysSullivan wants to merge 3 commits into
ema-client-authfrom
ema-posthog-flag
Closed

Gate enterprise-managed authorization behind a PostHog flag#1740
RhysSullivan wants to merge 3 commits into
ema-client-authfrom
ema-posthog-flag

Conversation

@RhysSullivan

Copy link
Copy Markdown
Collaborator

Stacked on #1730. Puts the enterprise-managed authorization path behind a PostHog feature flag so it can be rolled out to real users gradually.

Shape

The SDK stays vendor-free: the gate is a host-owned seam injected alongside the existing fetch and HTTP client dependencies, so local, desktop, CLI and self-hosted deployments keep working with no PostHog and no configuration. When no host injects a gate, the enterprise-managed path is attempted exactly as it is today.

apps/cloud implements the seam with a small fetch against PostHog's flag endpoint using the already-deployed public project key, rather than adding an SDK to the worker bundle. That is deliberate: a dependency added to this bundle previously produced a large, never-explained page-load regression, so the cheap call is the conservative choice.

Rollout is keyed on the userdistinct_id is the acting user's id, matching the identify call the web app already makes — with the organization passed as group context so group targeting stays available without changing the user-level rollout. Flag key: mcp-enterprise-managed-auth.

Behaviour

  • The gate is evaluated once, at connect, before discovery. When it withholds, connect falls back to the ordinary interactive flow along the same path used when a server does not advertise the grant profile.
  • It is never consulted after an identity-provider denial. A flag readable after a denial would be an escape hatch around the administrator control the feature exists to enforce, so the ordering is pinned by a test rather than left to convention.
  • Renewal never re-evaluates. The decision is persisted on the connection and the credential-refresh path follows it, which keeps a third-party network dependency out of credential resolution. Turning the flag off therefore gates new connections only; existing managed connections are unaffected. A true kill switch would be a separate, deliberate control, since silently converting an organization-governed connection into a personal one is a security-relevant event.
  • Every failure fails closed. Timeout, transport error, non-2xx, unrecognised body, missing configuration, or no acting user all withhold the enterprise-managed path and fall back to interactive. Evaluation can never fail the connect request itself.

Analytics

Connect outcomes are captured as ema_connect_attempted, ema_connect_connected and ema_connect_blocked_by_admin, each carrying the flag decision, and the blocked event carrying the identity provider's own error code. Capture is handed to the platform rather than awaited, so it cannot delay or fail a connect. A test asserts no token, assertion or other credential material can reach event properties.

Tests

8 new tests in the SDK covering allow, withhold, evaluation failure, the no-gate default, the never-after-denial ordering, the no-re-evaluation-on-renewal property, credential exclusion from events, and an observer that throws. 17 new tests in the cloud implementation covering the user/group payload, each failure mode failing closed, event contents, and fire-and-forget capture.

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Console https://executor-preview-pr-1740.executor-e2e.workers.dev
MCP https://executor-preview-pr-1740.executor-e2e.workers.dev/mcp
Deployed commit 28dae26

Sign-in is Cloudflare Access (one-time PIN to an allowed email). The preview has its own database and encryption key; it is destroyed when this PR closes.

@pkg-pr-new

pkg-pr-new Bot commented Aug 25, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@1740

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@1740

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@1740

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@1740

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@1740

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@1740

executor

npm i https://pkg.pr.new/executor@1740

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@1740

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@1740

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@1740

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@1740

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@1740

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@1740

commit: 28dae26

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 25, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing 28dae26 Commit Preview URL

Branch Preview URL
Aug 26 2026, 09:56 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 25, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud 28dae26 Aug 26 2026, 09:58 PM

@RhysSullivan
RhysSullivan deleted the branch ema-client-auth August 26, 2026 22:03
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.

1 participant