Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
geokat wants to merge8 commits intomain
base:main
Choose a base branch
Loading
fromgeokat/internal-1073-organization-disable-workspace-sharing-option

Conversation

@geokat
Copy link
Contributor

@geokatgeokat commentedDec 16, 2025
edited
Loading

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

Theorganization-member role 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

Storeorganization-member roles per-org in thecustom_roles table with anis_system flag. Create the roles during org creation and reconcile them at startup to keep permissions in sync with the codebase.

  1. Schema Changes
  • Addedis_system boolean column to thecustom_roles table — marks Coder-managed roles
  • Addedmember_permissions — for member-scoped permissions (resources owned by the user)
  • Addedworkspace_sharing_disabled toorganizations — per-org setting
  1. Migration
  • Brings existing organizations up to date by creating empty placeholderorganization-member system roles for all existing organizations
  • Permissions are empty initially (eventually backfilled by the startup reconciliation hook)
  1. Permission Generation (coderd/rbac/roles.go)
  • OrgMemberPermissions(workspaceSharingDisabled bool) is the source of truth
  • Generates org-level and member-level permissions dynamically
  • Respects the workspace sharing setting (adds negation forActionShare when disabled)
  1. Org Creation Hook (enterprise/coderd/organizations.go)
  • When a new org is created, a placeholderorganization-member role is created by a trigger in the DB.
  • ReconcileOrgMemberRoles() is called to populate the role with permissions.
  1. Startup Reconciliation (coderd/systemroles.go)
  • ReconcileOrgMemberRoles() runs at startup with an advisory lock
  • Compares expected vs stored permissions using set-based comparison
  • Updates roles if permissions differ (due to the initial migration or RBAC resource changes)
  • Blocking lock ensures each instance reconciles, catching orgs created by old instances

Key Design Decisions

DecisionRationale
Permissions as source of truth in codeMoving them to the DB is a big project; duplicating them in the DB is error-prone
Introduce system rolesis_system =true makes them transparent to the CRUD API
Startup reconciliationResource type changes in code are propagated to roles stored in the DB
Set-based comparisonAvoids unnecessary writes when permissions are unchanged
Blocking advisory lockEnsures correctness during rolling upgrades

closes:coder/internal#1073

@bpmctbpmct added the doc-checkAssign this label to PRs to check for any doc changes. labelDec 16, 2025
@geokat
Copy link
ContributorAuthor

@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.

@geokatgeokatforce-pushed thegeokat/internal-1073-organization-disable-workspace-sharing-option branch 5 times, most recently from9614436 to9b7cfc9CompareDecember 17, 2025 23:37
@geokatgeokatforce-pushed thegeokat/internal-1073-organization-disable-workspace-sharing-option branch from9b7cfc9 to764fd62CompareDecember 18, 2025 04:06
… rolesThe startup hook (ReconcileOrgMemberRoles) already handles role creationwith advisory locking. The migration only created empty placeholders withno permission effect.
@geokatgeokatforce-pushed thegeokat/internal-1073-organization-disable-workspace-sharing-option branch from43aed93 tocac2ef2CompareDecember 18, 2025 18:20
@geokatgeokatforce-pushed thegeokat/internal-1073-organization-disable-workspace-sharing-option branch 2 times, most recently from04c2822 to27753a1CompareDecember 19, 2025 00:57
@geokatgeokatforce-pushed thegeokat/internal-1073-organization-disable-workspace-sharing-option branch from27753a1 toa619e7aCompareDecember 19, 2025 01:18
@geokatgeokatforce-pushed thegeokat/internal-1073-organization-disable-workspace-sharing-option branch from3a3c183 to689626aCompareDecember 19, 2025 04:18
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@EmyrkEmyrkAwaiting requested review from EmyrkEmyrk will be requested when the pull request is marked ready for reviewEmyrk is a code owner

At least 1 approving review is required to merge this pull request.

Assignees

@geokatgeokat

Labels

doc-checkAssign this label to PRs to check for any doc changes.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Implement organization "disable workspace sharing" option

3 participants

@geokat@bpmct

[8]ページ先頭

©2009-2025 Movatter.jp