Scope MCP OAuth tokens to user + workspace (#222) - #223
Closed
paulocastellano wants to merge 3 commits into
Closed
Conversation
Bind authorization-code grants to the authorizing workspace (via auth codes), inherit workspace on refresh, resolve MCP/API requests from the token instead of current_workspace_id, backfill existing grants, and revoke workspace tokens when a member is removed. Co-authored-by: Paulo Castellano <hello@paulocastellano.com>
Decrypt League auth-code and refresh-token request payloads to resolve workspace_id correctly, prefer Auth::user() at consent (including silent re-consent), and cover multi-workspace refresh / reconnect edge cases. Co-authored-by: Paulo Castellano <hello@paulocastellano.com>
Fail the OAuth grant with invalid_grant when a workspace cannot be bound, centralize access/refresh token revocation, and remove N+1 queries from the MCP OAuth workspace backfill. Co-authored-by: Paulo Castellano <hello@paulocastellano.com>
22 tasks
Contributor
Author
Contributor
Author
|
Closing in favor of #245. |
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.
Closes #222.
Summary
MCP OAuth tokens (Claude/ChatGPT connectors) are now scoped to user + workspace, matching personal API keys. Requests resolve the workspace from the token instead of the user's
current_workspace_id, so a multi-workspace agent cannot silently act on the wrong tenant.Decisions
Auth::user()->current_workspace_idat consent (including silent re-consent) + membership check.oauth_auth_codes.workspace_id; listener decrypts League's encryptedcode(auth_code_id) and copies workspace.refresh_token→ inherit that specificaccess_token_id's workspace.invalid_grant(no success response with a dead token).RemoveMemberrevokes that user's tokens for the removed workspace via sharedRevokeAccessTokens.personalAccess()grant type.mainyet).Review hardening
invalid_grant.Test plan
invalid_grant+ revoked tokenRevokeAccessTokensrevokes refresh tokens