@@ -27,8 +27,11 @@ const (
27
27
customSiteRole string = "custom-site-role"
28
28
customOrganizationRole string = "custom-organization-role"
29
29
30
- orgAdmin string = "organization-admin"
31
- orgMember string = "organization-member"
30
+ orgAdmin string = "organization-admin"
31
+ orgMember string = "organization-member"
32
+ orgAuditor string = "organization-auditor"
33
+ orgUserAdmin string = "organization-user-admin"
34
+ orgTemplateAdmin string = "organization-template-admin"
32
35
)
33
36
34
37
func init () {
@@ -144,18 +147,38 @@ func RoleOrgMember() string {
144
147
return orgMember
145
148
}
146
149
150
+ func RoleOrgAuditor () string {
151
+ return orgAuditor
152
+ }
153
+
154
+ func RoleOrgUserAdmin () string {
155
+ return orgUserAdmin
156
+ }
157
+
158
+ func RoleOrgTemplateAdmin () string {
159
+ return orgTemplateAdmin
160
+ }
161
+
147
162
// ScopedRoleOrgAdmin is the org role with the organization ID
148
- // Deprecated This was used before organization scope was included as a
149
- // field in all user facing APIs. Usage of 'ScopedRoleOrgAdmin()' is preferred.
150
163
func ScopedRoleOrgAdmin (organizationID uuid.UUID ) RoleIdentifier {
151
- return RoleIdentifier {Name : orgAdmin , OrganizationID : organizationID }
164
+ return RoleIdentifier {Name : RoleOrgAdmin () , OrganizationID : organizationID }
152
165
}
153
166
154
167
// ScopedRoleOrgMember is the org role with the organization ID
155
- // Deprecated This was used before organization scope was included as a
156
- // field in all user facing APIs. Usage of 'ScopedRoleOrgMember()' is preferred.
157
168
func ScopedRoleOrgMember (organizationID uuid.UUID ) RoleIdentifier {
158
- return RoleIdentifier {Name : orgMember , OrganizationID : organizationID }
169
+ return RoleIdentifier {Name : RoleOrgMember (), OrganizationID : organizationID }
170
+ }
171
+
172
+ func ScopedRoleOrgAuditor (organizationID uuid.UUID ) RoleIdentifier {
173
+ return RoleIdentifier {Name : RoleOrgAuditor (), OrganizationID : organizationID }
174
+ }
175
+
176
+ func ScopedRoleOrgUserAdmin (organizationID uuid.UUID ) RoleIdentifier {
177
+ return RoleIdentifier {Name : RoleOrgUserAdmin (), OrganizationID : organizationID }
178
+ }
179
+
180
+ func ScopedRoleOrgTemplateAdmin (organizationID uuid.UUID ) RoleIdentifier {
181
+ return RoleIdentifier {Name : RoleOrgTemplateAdmin (), OrganizationID : organizationID }
159
182
}
160
183
161
184
func allPermsExcept (excepts ... Objecter ) []Permission {
@@ -365,7 +388,11 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
365
388
return Role {
366
389
Identifier : RoleIdentifier {Name : orgAdmin , OrganizationID : organizationID },
367
390
DisplayName : "Organization Admin" ,
368
- Site : []Permission {},
391
+ Site : Permissions (map [string ][]policy.Action {
392
+ // To assign organization members, we need to be able to read
393
+ // users at the site wide to know they exist.
394
+ ResourceUser .Type : {policy .ActionRead },
395
+ }),
369
396
Org : map [string ][]Permission {
370
397
// Org admins should not have workspace exec perms.
371
398
organizationID .String (): append (allPermsExcept (ResourceWorkspace , ResourceWorkspaceDormant , ResourceAssignRole ), Permissions (map [string ][]policy.Action {
@@ -377,8 +404,7 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
377
404
}
378
405
},
379
406
380
- // orgMember has an empty set of permissions, this just implies their membership
381
- // in an organization.
407
+ // orgMember is an implied role to any member in an organization.
382
408
orgMember : func (organizationID uuid.UUID ) Role {
383
409
return Role {
384
410
Identifier : RoleIdentifier {Name : orgMember , OrganizationID : organizationID },
@@ -406,6 +432,59 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
406
432
},
407
433
}
408
434
},
435
+ orgAuditor : func (organizationID uuid.UUID ) Role {
436
+ return Role {
437
+ Identifier : RoleIdentifier {Name : orgAuditor , OrganizationID : organizationID },
438
+ DisplayName : "Organization Auditor" ,
439
+ Site : []Permission {},
440
+ Org : map [string ][]Permission {
441
+ organizationID .String (): Permissions (map [string ][]policy.Action {
442
+ ResourceAuditLog .Type : {policy .ActionRead },
443
+ }),
444
+ },
445
+ User : []Permission {},
446
+ }
447
+ },
448
+ orgUserAdmin : func (organizationID uuid.UUID ) Role {
449
+ // Manages organization members and groups.
450
+ return Role {
451
+ Identifier : RoleIdentifier {Name : orgUserAdmin , OrganizationID : organizationID },
452
+ DisplayName : "Organization User Admin" ,
453
+ Site : Permissions (map [string ][]policy.Action {
454
+ // To assign organization members, we need to be able to read
455
+ // users at the site wide to know they exist.
456
+ ResourceUser .Type : {policy .ActionRead },
457
+ }),
458
+ Org : map [string ][]Permission {
459
+ organizationID .String (): Permissions (map [string ][]policy.Action {
460
+ // Assign, remove, and read roles in the organization.
461
+ ResourceAssignOrgRole .Type : {policy .ActionAssign , policy .ActionDelete , policy .ActionRead },
462
+ ResourceOrganizationMember .Type : {policy .ActionCreate , policy .ActionRead , policy .ActionUpdate , policy .ActionDelete },
463
+ ResourceGroup .Type : ResourceGroup .AvailableActions (),
464
+ }),
465
+ },
466
+ User : []Permission {},
467
+ }
468
+ },
469
+ orgTemplateAdmin : func (organizationID uuid.UUID ) Role {
470
+ // Manages organization members and groups.
471
+ return Role {
472
+ Identifier : RoleIdentifier {Name : orgTemplateAdmin , OrganizationID : organizationID },
473
+ DisplayName : "Organization Template Admin" ,
474
+ Site : []Permission {},
475
+ Org : map [string ][]Permission {
476
+ organizationID .String (): Permissions (map [string ][]policy.Action {
477
+ ResourceTemplate .Type : {policy .ActionCreate , policy .ActionRead , policy .ActionUpdate , policy .ActionDelete , policy .ActionViewInsights },
478
+ ResourceFile .Type : {policy .ActionCreate , policy .ActionRead },
479
+ ResourceWorkspace .Type : {policy .ActionRead },
480
+ // Assigning template perms requires this permission.
481
+ ResourceOrganizationMember .Type : {policy .ActionRead },
482
+ ResourceGroup .Type : {policy .ActionRead },
483
+ }),
484
+ },
485
+ User : []Permission {},
486
+ }
487
+ },
409
488
}
410
489
}
411
490
@@ -421,6 +500,9 @@ var assignRoles = map[string]map[string]bool{
421
500
member : true ,
422
501
orgAdmin : true ,
423
502
orgMember : true ,
503
+ orgAuditor : true ,
504
+ orgUserAdmin : true ,
505
+ orgTemplateAdmin : true ,
424
506
templateAdmin : true ,
425
507
userAdmin : true ,
426
508
customSiteRole : true ,
@@ -432,6 +514,9 @@ var assignRoles = map[string]map[string]bool{
432
514
member : true ,
433
515
orgAdmin : true ,
434
516
orgMember : true ,
517
+ orgAuditor : true ,
518
+ orgUserAdmin : true ,
519
+ orgTemplateAdmin : true ,
435
520
templateAdmin : true ,
436
521
userAdmin : true ,
437
522
customSiteRole : true ,
@@ -444,8 +529,14 @@ var assignRoles = map[string]map[string]bool{
444
529
orgAdmin : {
445
530
orgAdmin : true ,
446
531
orgMember : true ,
532
+ orgAuditor : true ,
533
+ orgUserAdmin : true ,
534
+ orgTemplateAdmin : true ,
447
535
customOrganizationRole : true ,
448
536
},
537
+ orgUserAdmin : {
538
+ orgMember : true ,
539
+ },
449
540
}
450
541
451
542
// ExpandableRoles is any type that can be expanded into a []Role. This is implemented
0 commit comments