Conversation
Emyrk
reviewed
Dec 23, 2025
aslilac
reviewed
Dec 24, 2025
5a38c10 to
06f14ee
Compare
Emyrk
reviewed
Jan 5, 2026
Member
Emyrk
left a comment
There was a problem hiding this comment.
Is there no way to update the org setting at this moment?
Contributor
Author
Member
Perfect! |
7f9a717 to
3b8fdc6
Compare
Emyrk
reviewed
Jan 12, 2026
Emyrk
approved these changes
Jan 12, 2026
… system roles as an extra precaution
ba2c7a9 to
5467cd9
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Part of a series (2 stacked PRs) that closes coder/internal#1073
Migrating Org-Member Role to Database
Problem
The
organization-memberrole’s permissions are generated in code (the built-inorgMemberrole). This keeps it easy to evolve alongside RBAC resource changes, but it prevents per-organization variation (e.g. introducing and respecting an organization’sworkspace_sharing_disabledsetting).Solution: Database-Backed System Roles (per organization)
Store one
organization-memberrole per organization incustom_roleswithis_system=true. Create placeholder rows in the database (migration + trigger) and reconcile them at startup so the stored permissions stay in sync with the code-generated source of truth.1. Schema Changes
custom_roles.is_system(boolean) to mark Coder-managed roles.custom_roles.member_permissions(jsonb) to store member-scoped permissions (resources owned by the user).organizations.workspace_sharing_disabled(boolean) as a per-org setting.2. Migration + DB Trigger
3. Permission Generation (code is source of truth)
rbac.OrgMemberPermissions(workspaceSharingDisabled bool)in coderd/rbac/roles.go is the source of truth.member_permissions.workspace_sharing_disabled=true, it includes a negated permission forworkspace:shareto disable sharing.4. Org Creation (enterprise)
rolestore.ReconcileOrgMemberRole()(with a system-restricted auth context) to populate the role’s permissions immediately.5. Startup Reconciliation (system role maintenance)
rolestore.ReconcileSystemRoles().ReconcileSystemRoles:LockIDReconcileSystemRoles) to prevent concurrent reconciles across instances.organization-membersystem role exists.rbac.PermissionsEqual) and updates only when needed.Key Design Decisions
is_system=trueallows storing customized per-org roles while keeping them hidden from user-facing role CRUD.