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:
@@ -1,6 +1,7 @@
|
||||
package accesscontrol
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -10,7 +11,7 @@ import (
|
||||
|
||||
type RoleRegistry interface {
|
||||
// RegisterFixedRoles registers all roles declared to AccessControl
|
||||
RegisterFixedRoles() error
|
||||
RegisterFixedRoles(ctx context.Context) error
|
||||
}
|
||||
|
||||
// Roles definition
|
||||
@@ -276,3 +277,48 @@ func (m *RegistrationList) Range(f func(registration RoleRegistration) bool) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BuildMacroRoleDefinitions() map[string]*RoleDTO {
|
||||
return map[string]*RoleDTO{
|
||||
string(models.ROLE_ADMIN): {
|
||||
Name: "grafana:builtins:admin",
|
||||
UID: "grafana_builtins_admin",
|
||||
OrgID: GlobalOrgID,
|
||||
Version: 1,
|
||||
DisplayName: string(models.ROLE_ADMIN),
|
||||
Description: "Admin role",
|
||||
Group: "Basic",
|
||||
Permissions: []Permission{},
|
||||
},
|
||||
string(models.ROLE_EDITOR): {
|
||||
Name: "grafana:builtins:editor",
|
||||
UID: "grafana_builtins_editor",
|
||||
OrgID: GlobalOrgID,
|
||||
Version: 1,
|
||||
DisplayName: string(models.ROLE_EDITOR),
|
||||
Description: "Editor role",
|
||||
Group: "Basic",
|
||||
Permissions: []Permission{},
|
||||
},
|
||||
string(models.ROLE_VIEWER): {
|
||||
Name: "grafana:builtins:viewer",
|
||||
UID: "grafana_builtins_viewer",
|
||||
OrgID: GlobalOrgID,
|
||||
Version: 1,
|
||||
DisplayName: string(models.ROLE_VIEWER),
|
||||
Description: "Viewer role",
|
||||
Group: "Basic",
|
||||
Permissions: []Permission{},
|
||||
},
|
||||
RoleGrafanaAdmin: {
|
||||
Name: "grafana:builtins:grafana_admin",
|
||||
UID: "grafana_builtins_grafana_admin",
|
||||
OrgID: GlobalOrgID,
|
||||
Version: 1,
|
||||
DisplayName: RoleGrafanaAdmin,
|
||||
Description: "Grafana Admin role",
|
||||
Group: "Basic",
|
||||
Permissions: []Permission{},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user