- Notifications
You must be signed in to change notification settings - Fork909
Commit4633658
Cherry-picked feat: implement WorkspaceCreationBan org role (#16686)Using negative permissions, this role prevents a user's ability tocreate & delete a workspace within a given organization.Workspaces are uniquely owned by an org and a user, so the org has tosupercede the user permission with a negative permission.# Use caseOrganizations must be able to restrict a member's ability to create aworkspace. This permission is implicitly granted (see#16546 (comment)).To revoke this permission, the solution chosen was to use negativepermissions in a built in role called `WorkspaceCreationBan`.# RationalUsing negative permissions is new territory, and not ideal. However,workspaces are in a unique position.Workspaces have 2 owners. The organization and the user. To preventusers from creating a workspace in another organization, an [impliednegativepermission](https://github.com/coder/coder/blob/36d9f5ddb3d98029fee07d004709e1e51022e979/coderd/rbac/policy.rego#L172-L192)is used. So the truth table looks like: _how to read this table[here](https://github.com/coder/coder/blob/36d9f5ddb3d98029fee07d004709e1e51022e979/coderd/rbac/README.md#roles)_| Role (example) | Site | Org | User | Result ||-----------------|------|------|------|--------|| non-org-member | \_ | N | YN\_ | N || user | \_ | \_ | Y | Y || WorkspaceBan | \_ | N | Y | Y || unauthenticated | \_ | \_ | \_ | N |This new role, `WorkspaceCreationBan` is the same truth table conditionas if the user was not a member of the organization (when doing aworkspace create/delete). So this behavior **is not entirely new**.<details><summary>How to do it without a negative permission</summary>The alternate approach would be to remove the implied permission, andgrant it via and organization role. However this would add new behaviorthat an organizational role has the ability to grant a user permissionson their own resources?It does not make sense for an org role to prevent user from changingtheir profile information for example. So the only option is to create anew truth table column for resources that are owned by both anorganization and a user.| Role (example) | Site | Org |User+Org| User | Result ||-----------------|------|------|--------|------|--------|| non-org-member | \_ | N | \_ | \_ | N || user | \_ | \_ | \_ | \_ | N || WorkspaceAllow | \_ | \_ | Y | \_ | Y || unauthenticated | \_ | \_ | \_ | \_ | N |Now a user has no opinion on if they can create a workspace, which feelsa little wrong. A user should have the authority over what is theres.There is fundamental _philosophical_ question of "Who does a workspacebelong to?". The user has some set of autonomy, yet it is theorganization that controls it's existence. A head scratcher 🤔</details>## Will we need more negative built in roles?There are few resources that have shared ownership. Only`ResourceOrganizationMember` and `ResourceGroupMember`. Since negativepermissions is intended to revoke access to a shared resource, then**no.** **This is the only one we need**.Classic resources like `ResourceTemplate` are entirely controlled by theOrganization permissions. And resources entirely in the user control(like user profile) are only controlled by `User` permissions.![Uploading Screenshot 2025-02-26 at 22.26.52.png…]()---------Co-authored-by: Jaayden Halko <jaayden.halko@gmail.com>Co-authored-by: ケイラ <mckayla@hey.com>Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>Co-authored-by: Jaayden Halko <jaayden.halko@gmail.com>Co-authored-by: ケイラ <mckayla@hey.com>
1 parent6da3c9d commit4633658
File tree
11 files changed
+261
-65
lines changed- coderd
- httpapi
- rbac
- wsbuilder
- codersdk
- enterprise/coderd
- site/src
- api
- pages/OrganizationSettingsPage/UserTable
- testHelpers
11 files changed
+261
-65
lines changedLines changed: 6 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
151 | 151 |
| |
152 | 152 |
| |
153 | 153 |
| |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
154 | 159 |
| |
155 |
| - | |
156 |
| - | |
157 |
| - | |
158 |
| - | |
| 160 | + | |
159 | 161 |
| |
160 | 162 |
| |
161 | 163 |
| |
|
Lines changed: 72 additions & 35 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
30 |
| - | |
31 |
| - | |
32 |
| - | |
33 |
| - | |
34 |
| - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
35 | 36 |
| |
36 | 37 |
| |
37 | 38 |
| |
| |||
159 | 160 |
| |
160 | 161 |
| |
161 | 162 |
| |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
162 | 167 |
| |
163 | 168 |
| |
164 | 169 |
| |
| |||
181 | 186 |
| |
182 | 187 |
| |
183 | 188 |
| |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
184 | 193 |
| |
185 | 194 |
| |
186 | 195 |
| |
| |||
496 | 505 |
| |
497 | 506 |
| |
498 | 507 |
| |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
499 | 533 |
| |
500 | 534 |
| |
501 | 535 |
| |
| |||
506 | 540 |
| |
507 | 541 |
| |
508 | 542 |
| |
509 |
| - | |
510 |
| - | |
511 |
| - | |
512 |
| - | |
513 |
| - | |
514 |
| - | |
515 |
| - | |
516 |
| - | |
517 |
| - | |
518 |
| - | |
519 |
| - | |
520 |
| - | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
521 | 556 |
| |
522 | 557 |
| |
523 |
| - | |
524 |
| - | |
525 |
| - | |
526 |
| - | |
527 |
| - | |
528 |
| - | |
529 |
| - | |
530 |
| - | |
531 |
| - | |
532 |
| - | |
533 |
| - | |
534 |
| - | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
535 | 571 |
| |
536 | 572 |
| |
537 | 573 |
| |
538 | 574 |
| |
539 | 575 |
| |
540 | 576 |
| |
541 |
| - | |
542 |
| - | |
543 |
| - | |
544 |
| - | |
545 |
| - | |
546 |
| - | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
547 | 584 |
| |
548 | 585 |
| |
549 | 586 |
| |
|
Lines changed: 15 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
112 | 112 |
| |
113 | 113 |
| |
114 | 114 |
| |
| 115 | + | |
115 | 116 |
| |
116 | 117 |
| |
117 | 118 |
| |
| |||
181 | 182 |
| |
182 | 183 |
| |
183 | 184 |
| |
184 |
| - | |
| 185 | + | |
185 | 186 |
| |
186 | 187 |
| |
187 | 188 |
| |
188 | 189 |
| |
189 |
| - | |
| 190 | + | |
190 | 191 |
| |
191 |
| - | |
| 192 | + | |
192 | 193 |
| |
193 | 194 |
| |
194 | 195 |
| |
195 | 196 |
| |
196 | 197 |
| |
197 | 198 |
| |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
198 | 209 |
| |
199 | 210 |
| |
200 | 211 |
| |
| |||
942 | 953 |
| |
943 | 954 |
| |
944 | 955 |
| |
| 956 | + | |
945 | 957 |
| |
946 | 958 |
| |
947 | 959 |
| |
|
Lines changed: 48 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
375 | 375 |
| |
376 | 376 |
| |
377 | 377 |
| |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
378 | 426 |
| |
379 | 427 |
| |
380 | 428 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
790 | 790 |
| |
791 | 791 |
| |
792 | 792 |
| |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
793 | 802 |
| |
794 | 803 |
| |
795 | 804 |
| |
|
Lines changed: 6 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
12 |
| - | |
13 |
| - | |
14 |
| - | |
15 |
| - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
16 | 17 |
|
Lines changed: 15 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
441 | 441 |
| |
442 | 442 |
| |
443 | 443 |
| |
444 |
| - | |
445 |
| - | |
446 |
| - | |
447 |
| - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
448 | 449 |
| |
449 | 450 |
| |
450 | 451 |
| |
| |||
473 | 474 |
| |
474 | 475 |
| |
475 | 476 |
| |
476 |
| - | |
477 |
| - | |
478 |
| - | |
479 |
| - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
480 | 482 |
| |
481 | 483 |
| |
482 | 484 |
| |
| |||
505 | 507 |
| |
506 | 508 |
| |
507 | 509 |
| |
508 |
| - | |
509 |
| - | |
510 |
| - | |
511 |
| - | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
512 | 515 |
| |
513 | 516 |
| |
514 | 517 |
| |
|
Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4 | 4 |
| |
5 | 5 |
| |
6 | 6 |
| |
| 7 | + | |
7 | 8 |
| |
8 | 9 |
| |
9 | 10 |
| |
| |||
41 | 42 |
| |
42 | 43 |
| |
43 | 44 |
| |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + |
0 commit comments
Comments
(0)