- Notifications
You must be signed in to change notification settings - Fork1.1k
feat: implement organization "disable workspace sharing" option#21297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
feat: implement organization "disable workspace sharing" option#21297
Conversation
geokat commentedDec 16, 2025
@aslilac@Emyrk More work is needed to address all of thecoder/internal#1073 requirements, but I wanted to run this approach for migrating the built-in role by you early on. The code isn't ready for review yet, but it should demonstrate the pros and cons of the chosen approach. Other alternatives I can see--using the DB as the source of truth for permissions or duplicating them in the DB--seem to be more involved and error-prone than running reconciliation at startup. But please let me know if you disagree or have other ideas. |
9614436 to9b7cfc9Compare9b7cfc9 to764fd62Compare… rolesThe startup hook (ReconcileOrgMemberRoles) already handles role creationwith advisory locking. The migration only created empty placeholders withno permission effect.
43aed93 tocac2ef2Compare04c2822 to27753a1Compare27753a1 toa619e7aCompare3a3c183 to689626aCompare
Uh oh!
There was an error while loading.Please reload this page.
wip: the PR is currently in draft mode to discuss the migration of the org-member role to the DB
Migrating Org-Member Role to Database
Problem
The
organization-memberrole is hardcoded. This makes it easy to keep it in sync with resource types supported by Coder, but prevents per-org customization (e.g.,workspace_sharing_disabled).Solution: Database-Backed System Roles
Store
organization-memberroles per-org in thecustom_rolestable with anis_systemflag. Create the roles during org creation and reconcile them at startup to keep permissions in sync with the codebase.is_systemboolean column to thecustom_rolestable — marks Coder-managed rolesmember_permissions— for member-scoped permissions (resources owned by the user)workspace_sharing_disabledtoorganizations— per-org settingorganization-membersystem roles for all existing organizationsOrgMemberPermissions(workspaceSharingDisabled bool)is the source of truthActionSharewhen disabled)organization-memberrole is created by a trigger in the DB.ReconcileOrgMemberRoles()is called to populate the role with permissions.ReconcileOrgMemberRoles()runs at startup with an advisory lockKey Design Decisions
is_system=truemakes them transparent to the CRUD APIcloses:coder/internal#1073