@@ -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 {
@@ -377,8 +400,7 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
377
400
}
378
401
},
379
402
380
- // orgMember has an empty set of permissions, this just implies their membership
381
- // in an organization.
403
+ // orgMember is an implied role to any member in an organization.
382
404
orgMember :func (organizationID uuid.UUID )Role {
383
405
return Role {
384
406
Identifier :RoleIdentifier {Name :orgMember ,OrganizationID :organizationID },
@@ -406,6 +428,55 @@ func ReloadBuiltinRoles(opts *RoleOptions) {
406
428
},
407
429
}
408
430
},
431
+ orgAuditor :func (organizationID uuid.UUID )Role {
432
+ return Role {
433
+ Identifier :RoleIdentifier {Name :orgAuditor ,OrganizationID :organizationID },
434
+ DisplayName :"Organization Auditor" ,
435
+ Site : []Permission {},
436
+ Org :map [string ][]Permission {
437
+ organizationID .String ():Permissions (map [string ][]policy.Action {
438
+ ResourceAuditLog .Type : {policy .ActionRead },
439
+ }),
440
+ },
441
+ User : []Permission {},
442
+ }
443
+ },
444
+ orgUserAdmin :func (organizationID uuid.UUID )Role {
445
+ // Manages organization members and groups.
446
+ return Role {
447
+ Identifier :RoleIdentifier {Name :orgUserAdmin ,OrganizationID :organizationID },
448
+ DisplayName :"Organization User Admin" ,
449
+ Site : []Permission {},
450
+ Org :map [string ][]Permission {
451
+ organizationID .String ():Permissions (map [string ][]policy.Action {
452
+ // Assign, remove, and read roles in the organization.
453
+ ResourceAssignOrgRole .Type : {policy .ActionAssign ,policy .ActionDelete ,policy .ActionRead },
454
+ ResourceOrganizationMember .Type : {policy .ActionCreate ,policy .ActionRead ,policy .ActionUpdate ,policy .ActionDelete },
455
+ ResourceGroup .Type :ResourceGroup .AvailableActions (),
456
+ }),
457
+ },
458
+ User : []Permission {},
459
+ }
460
+ },
461
+ orgTemplateAdmin :func (organizationID uuid.UUID )Role {
462
+ // Manages organization members and groups.
463
+ return Role {
464
+ Identifier :RoleIdentifier {Name :orgTemplateAdmin ,OrganizationID :organizationID },
465
+ DisplayName :"Organization Template Admin" ,
466
+ Site : []Permission {},
467
+ Org :map [string ][]Permission {
468
+ organizationID .String ():Permissions (map [string ][]policy.Action {
469
+ ResourceTemplate .Type : {policy .ActionCreate ,policy .ActionRead ,policy .ActionUpdate ,policy .ActionDelete ,policy .ActionViewInsights },
470
+ ResourceFile .Type : {policy .ActionCreate ,policy .ActionRead },
471
+ ResourceWorkspace .Type : {policy .ActionRead },
472
+ // Assigning template perms requires this permission.
473
+ ResourceOrganizationMember .Type : {policy .ActionRead },
474
+ ResourceGroup .Type : {policy .ActionRead },
475
+ }),
476
+ },
477
+ User : []Permission {},
478
+ }
479
+ },
409
480
}
410
481
}
411
482
@@ -421,6 +492,9 @@ var assignRoles = map[string]map[string]bool{
421
492
member :true ,
422
493
orgAdmin :true ,
423
494
orgMember :true ,
495
+ orgAuditor :true ,
496
+ orgUserAdmin :true ,
497
+ orgTemplateAdmin :true ,
424
498
templateAdmin :true ,
425
499
userAdmin :true ,
426
500
customSiteRole :true ,
@@ -432,6 +506,9 @@ var assignRoles = map[string]map[string]bool{
432
506
member :true ,
433
507
orgAdmin :true ,
434
508
orgMember :true ,
509
+ orgAuditor :true ,
510
+ orgUserAdmin :true ,
511
+ orgTemplateAdmin :true ,
435
512
templateAdmin :true ,
436
513
userAdmin :true ,
437
514
customSiteRole :true ,
@@ -444,8 +521,14 @@ var assignRoles = map[string]map[string]bool{
444
521
orgAdmin : {
445
522
orgAdmin :true ,
446
523
orgMember :true ,
524
+ orgAuditor :true ,
525
+ orgUserAdmin :true ,
526
+ orgTemplateAdmin :true ,
447
527
customOrganizationRole :true ,
448
528
},
529
+ orgUserAdmin : {
530
+ orgMember :true ,
531
+ },
449
532
}
450
533
451
534
// ExpandableRoles is any type that can be expanded into a []Role. This is implemented