feat: Scope oauth tokens by org#2364
Open
charlesvien wants to merge 4 commits into
Open
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced May 25, 2026
Contributor
What T-Rex did
ArtifactsVerbose Vitest output for generated auth-service repros
Generated targeted auth-service repro test
|
c8e3d0e to
1382e6f
Compare
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
Multi-org users can only see and access projects from their current PostHog organization. The renderer derives projects from
currentUser.organization.teams, which only contains the active org, so switching to or paying for other orgs requires leaving the app.Changes
scoped_teamswith org-scoped tokens and aorgProjectsMap: Record<orgId, {orgName, projects}>onAuthState/api/organizations/{org_id}/projects/per scoped org during session bootstrapauth.switchOrgtRPC that PATCHes/api/users/@me/and rememberslastSelectedProjectIdper orguseProjectsto derive from the map only, removing theuseCurrentUserdependency and the project-info N+1OAUTH_SCOPE_VERSION4 to 5 so existing users re-auth into org-scoped tokenscurrentUserquery key betweenauthStore.syncAuthStateanduseCurrentUserHow did you test this?
manually
Publish to changelog?
no