fix(encrypted-secrets): store tokens at org partition for Service Token compatibility#1398
Closed
myohei wants to merge 1 commit into
Closed
fix(encrypted-secrets): store tokens at org partition for Service Token compatibility#1398myohei wants to merge 1 commit into
myohei wants to merge 1 commit into
Conversation
…ct visibility When using Service Token auth (e.g. MCP clients via Cloudflare Access), tokens saved during browser OAuth (by a human subject) were invisible to the Service Token subject due to the owner-read policy on plugin_storage. Always store encrypted secrets at owner='org' so any subject within the tenant can retrieve them. Access control remains enforced by the connection row's (tenant, owner, subject) partition.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When using Service Token authentication (e.g. MCP clients via Cloudflare Access), OAuth tokens saved during browser OAuth (by a human subject) are invisible to the Service Token subject.
This causes
oauth_connection_missing/oauth_reauth_requirederrors when an MCP client (authenticated with a Service Token) tries to call a tool on an integration whose OAuth was completed in the browser.Root Cause
The
encrypted-secretsprovider'sownerOf()returns"user"when the executor has a non-null subject. During browser OAuth, the token is stored at:During Service Token API calls, the
plugin_storageonReadpolicy filters by:The Service Token has a different
subject(common_name), so the stored token row is invisible →null→ connection appears to have no credential.Fix
Always store encrypted secrets at
owner='org'so any subject within the tenant (human user or Service Token) can retrieve them.Access control remains enforced by the connection row's
(tenant, owner, subject)partition — the provider is a shared, opaque-key vault.Test
Added a cross-subject visibility test that mirrors the real
onReadpolicy, verifying that a token stored by one subject is retrievable by another within the same tenant.