- Notifications
You must be signed in to change notification settings - Fork1k
chore: add built in organization roles to match site#13938
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
c071985
3685b18
2ab3be7
a1124d1
4718636
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -27,8 +27,11 @@ const ( | ||
customSiteRole string = "custom-site-role" | ||
customOrganizationRole string = "custom-organization-role" | ||
orgAdmin string = "organization-admin" | ||
orgMember string = "organization-member" | ||
orgAuditor string = "organization-auditor" | ||
orgUserAdmin string = "organization-user-admin" | ||
orgTemplateAdmin string = "organization-template-admin" | ||
) | ||
func init() { | ||
@@ -144,18 +147,38 @@ func RoleOrgMember() string { | ||
return orgMember | ||
} | ||
func RoleOrgAuditor() string { | ||
return orgAuditor | ||
} | ||
func RoleOrgUserAdmin() string { | ||
return orgUserAdmin | ||
} | ||
func RoleOrgTemplateAdmin() string { | ||
return orgTemplateAdmin | ||
} | ||
// ScopedRoleOrgAdmin is the org role with the organization ID | ||
func ScopedRoleOrgAdmin(organizationID uuid.UUID) RoleIdentifier { | ||
return RoleIdentifier{Name:RoleOrgAdmin(), OrganizationID: organizationID} | ||
} | ||
// ScopedRoleOrgMember is the org role with the organization ID | ||
func ScopedRoleOrgMember(organizationID uuid.UUID) RoleIdentifier { | ||
return RoleIdentifier{Name: RoleOrgMember(), OrganizationID: organizationID} | ||
} | ||
func ScopedRoleOrgAuditor(organizationID uuid.UUID) RoleIdentifier { | ||
return RoleIdentifier{Name: RoleOrgAuditor(), OrganizationID: organizationID} | ||
} | ||
func ScopedRoleOrgUserAdmin(organizationID uuid.UUID) RoleIdentifier { | ||
return RoleIdentifier{Name: RoleOrgUserAdmin(), OrganizationID: organizationID} | ||
} | ||
func ScopedRoleOrgTemplateAdmin(organizationID uuid.UUID) RoleIdentifier { | ||
return RoleIdentifier{Name: RoleOrgTemplateAdmin(), OrganizationID: organizationID} | ||
} | ||
func allPermsExcept(excepts ...Objecter) []Permission { | ||
@@ -365,7 +388,11 @@ func ReloadBuiltinRoles(opts *RoleOptions) { | ||
return Role{ | ||
Identifier: RoleIdentifier{Name: orgAdmin, OrganizationID: organizationID}, | ||
DisplayName: "Organization Admin", | ||
Site: Permissions(map[string][]policy.Action{ | ||
// To assign organization members, we need to be able to read | ||
// users at the site wide to know they exist. | ||
ResourceUser.Type: {policy.ActionRead}, | ||
}), | ||
Comment on lines +391 to +395 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This is unfortunate, but to add a user to an org, we need to know that user exists. | ||
Org: map[string][]Permission{ | ||
// Org admins should not have workspace exec perms. | ||
organizationID.String(): append(allPermsExcept(ResourceWorkspace, ResourceWorkspaceDormant, ResourceAssignRole), Permissions(map[string][]policy.Action{ | ||
@@ -377,8 +404,7 @@ func ReloadBuiltinRoles(opts *RoleOptions) { | ||
} | ||
}, | ||
// orgMember is an implied role to any member in an organization. | ||
orgMember: func(organizationID uuid.UUID) Role { | ||
return Role{ | ||
Identifier: RoleIdentifier{Name: orgMember, OrganizationID: organizationID}, | ||
@@ -406,6 +432,59 @@ func ReloadBuiltinRoles(opts *RoleOptions) { | ||
}, | ||
} | ||
}, | ||
orgAuditor: func(organizationID uuid.UUID) Role { | ||
return Role{ | ||
Identifier: RoleIdentifier{Name: orgAuditor, OrganizationID: organizationID}, | ||
DisplayName: "Organization Auditor", | ||
Site: []Permission{}, | ||
Org: map[string][]Permission{ | ||
organizationID.String(): Permissions(map[string][]policy.Action{ | ||
ResourceAuditLog.Type: {policy.ActionRead}, | ||
}), | ||
}, | ||
User: []Permission{}, | ||
} | ||
}, | ||
orgUserAdmin: func(organizationID uuid.UUID) Role { | ||
// Manages organization members and groups. | ||
return Role{ | ||
Identifier: RoleIdentifier{Name: orgUserAdmin, OrganizationID: organizationID}, | ||
DisplayName: "Organization User Admin", | ||
Site: Permissions(map[string][]policy.Action{ | ||
// To assign organization members, we need to be able to read | ||
// users at the site wide to know they exist. | ||
ResourceUser.Type: {policy.ActionRead}, | ||
}), | ||
Comment on lines +453 to +457 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This needs to be fixed by only needing the org member read permission. But | ||
Org: map[string][]Permission{ | ||
organizationID.String(): Permissions(map[string][]policy.Action{ | ||
// Assign, remove, and read roles in the organization. | ||
ResourceAssignOrgRole.Type: {policy.ActionAssign, policy.ActionDelete, policy.ActionRead}, | ||
ResourceOrganizationMember.Type: {policy.ActionCreate, policy.ActionRead, policy.ActionUpdate, policy.ActionDelete}, | ||
ResourceGroup.Type: ResourceGroup.AvailableActions(), | ||
}), | ||
}, | ||
User: []Permission{}, | ||
} | ||
}, | ||
orgTemplateAdmin: func(organizationID uuid.UUID) Role { | ||
// Manages organization members and groups. | ||
return Role{ | ||
Identifier: RoleIdentifier{Name: orgTemplateAdmin, OrganizationID: organizationID}, | ||
DisplayName: "Organization Template Admin", | ||
Site: []Permission{}, | ||
Org: map[string][]Permission{ | ||
organizationID.String(): Permissions(map[string][]policy.Action{ | ||
ResourceTemplate.Type: {policy.ActionCreate, policy.ActionRead, policy.ActionUpdate, policy.ActionDelete, policy.ActionViewInsights}, | ||
ResourceFile.Type: {policy.ActionCreate, policy.ActionRead}, | ||
ResourceWorkspace.Type: {policy.ActionRead}, | ||
// Assigning template perms requires this permission. | ||
ResourceOrganizationMember.Type: {policy.ActionRead}, | ||
ResourceGroup.Type: {policy.ActionRead}, | ||
}), | ||
}, | ||
User: []Permission{}, | ||
} | ||
}, | ||
} | ||
} | ||
@@ -421,6 +500,9 @@ var assignRoles = map[string]map[string]bool{ | ||
member: true, | ||
orgAdmin: true, | ||
orgMember: true, | ||
orgAuditor: true, | ||
orgUserAdmin: true, | ||
orgTemplateAdmin: true, | ||
templateAdmin: true, | ||
userAdmin: true, | ||
customSiteRole: true, | ||
@@ -432,6 +514,9 @@ var assignRoles = map[string]map[string]bool{ | ||
member: true, | ||
orgAdmin: true, | ||
orgMember: true, | ||
orgAuditor: true, | ||
orgUserAdmin: true, | ||
orgTemplateAdmin: true, | ||
templateAdmin: true, | ||
userAdmin: true, | ||
customSiteRole: true, | ||
@@ -444,8 +529,14 @@ var assignRoles = map[string]map[string]bool{ | ||
orgAdmin: { | ||
orgAdmin: true, | ||
orgMember: true, | ||
orgAuditor: true, | ||
orgUserAdmin: true, | ||
orgTemplateAdmin: true, | ||
customOrganizationRole: true, | ||
}, | ||
orgUserAdmin: { | ||
orgMember: true, | ||
}, | ||
} | ||
// ExpandableRoles is any type that can be expanded into a []Role. This is implemented | ||
Uh oh!
There was an error while loading.Please reload this page.