Skip to content

Make Sprocket the source of truth for org-team permissions (#726)#738

Draft
gankoji wants to merge 1 commit intomainfrom
cursor/issue-726-org-team-permissions-9d08
Draft

Make Sprocket the source of truth for org-team permissions (#726)#738
gankoji wants to merge 1 commit intomainfrom
cursor/issue-726-org-team-permissions-9d08

Conversation

@gankoji
Copy link
Copy Markdown
Member

@gankoji gankoji commented Apr 13, 2026

Summary

Implements GitHub issue #726: org-team / LO-style permission bits used in JWTs and guards now persist in Sprocket (sprocket.user_org_team_permission) instead of reading mledb.player_to_org on every login/refresh.

What changed

  • New table sprocket.user_org_team_permission (migration 1770500000000-UserOrgTeamPermission) with unique (userId, orgTeam) and FK to sprocket.user.
  • UserOrgTeamPermissionService — list/replace/add/remove permissions.
  • OrgTeamPermissionResolutionService — resolves org teams for a user id; prefers Sprocket rows.
  • Login / refresh (OauthController) — builds orgTeams from resolution (no direct player_to_org reads).
  • loginAsUser — copies target user’s resolved org teams into the short-lived token.
  • ReplayParseService — LO/admin override uses resolution instead of MLEDB.
  • FormerPlayerScrimGuard — short-circuits for LO/admin via resolution; still uses MLE player for the FP check (guard is now a proper MledbInterfaceModule provider).
  • Admin GraphQL (MLEDB admin guard): userOrgTeamPermissions, setUserOrgTeamPermissions, addUserOrgTeamPermission, removeUserOrgTeamPermission.
  • Docs: reports/issue-726-org-team-permissions.md — source of truth, env flag, removal plan.

Dual-read compatibility (temporary)

If a user has no Sprocket permission rows and ORG_TEAM_PERMISSION_DUAL_READ=true, resolution falls back to legacy mledb.player_to_org. Default is off so fresh environments do not hit MLEDB for auth until data is migrated or the flag is enabled during cutover.

Proof

  • npm run build --workspace=core (passes).

Follow-ups (not in this PR)

  • Backfill script or one-off job: copy player_to_orguser_org_team_permission for existing users.
  • After backfill: disable ORG_TEAM_PERMISSION_DUAL_READ and remove the fallback code path.
Open in Web Open in Cursor 

- Add sprocket.user_org_team_permission table and TypeORM entity
- Resolve JWT org teams from Sprocket; optional ORG_TEAM_PERMISSION_DUAL_READ MLEDB fallback
- Admin GraphQL CRUD for org-team permissions; wire loginAsUser and replay-parse override
- Register FormerPlayerScrimGuard in MledbInterfaceModule for DI
- Document source of truth and removal plan in reports/

Co-authored-by: Jake Bailey <asaxplayinghorse@gmail.com>
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.

2 participants