mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AccessControl: Make the built-in role definitions public (#47525)
* AccessControl: Make the built-in role definitions public * Add context to RegisterFixedRoles Co-authored-by: Jguer <joao.guerreiro@grafana.com> * Making BuiltInRolesWithParents public to the AccessControl package Co-authored-by: Jguer <joao.guerreiro@grafana.com> Co-authored-by: Jguer <joao.guerreiro@grafana.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/annotations"
|
||||
)
|
||||
|
||||
@@ -82,6 +83,7 @@ func (r RoleDTO) Role() Role {
|
||||
ID: r.ID,
|
||||
OrgID: r.OrgID,
|
||||
UID: r.UID,
|
||||
Version: r.Version,
|
||||
Name: r.Name,
|
||||
DisplayName: r.DisplayName,
|
||||
Group: r.Group,
|
||||
@@ -244,6 +246,9 @@ type SetResourcePermissionCommand struct {
|
||||
|
||||
const (
|
||||
GlobalOrgID = 0
|
||||
FixedRolePrefix = "fixed:"
|
||||
RoleGrafanaAdmin = "Grafana Admin"
|
||||
|
||||
GeneralFolderUID = "general"
|
||||
|
||||
// Permission actions
|
||||
@@ -385,6 +390,17 @@ var (
|
||||
ScopeAnnotationsTypeOrganization = ScopeAnnotationsProvider.GetResourceScopeType(annotations.Organization.String())
|
||||
)
|
||||
|
||||
const RoleGrafanaAdmin = "Grafana Admin"
|
||||
func BuiltInRolesWithParents(builtInRoles []string) map[string]struct{} {
|
||||
res := map[string]struct{}{}
|
||||
|
||||
const FixedRolePrefix = "fixed:"
|
||||
for _, br := range builtInRoles {
|
||||
res[br] = struct{}{}
|
||||
if br != RoleGrafanaAdmin {
|
||||
for _, parent := range models.RoleType(br).Parents() {
|
||||
res[string(parent)] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user