mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Move SignedInUser to user service and RoleType and Roles to org (#53445)
* Move SignedInUser to user service and RoleType and Roles to org * Use go naming convention for roles * Fix some imports and leftovers * Fix ldap debug test * Fix lint * Fix lint 2 * Fix lint 3 * Fix type and not needed conversion * Clean up messages in api tests * Clean up api tests 2
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
)
|
||||
|
||||
// Roles definition
|
||||
@@ -181,11 +181,11 @@ func DeclareFixedRoles(ac AccessControl) error {
|
||||
}
|
||||
orgUsersReader := RoleRegistration{
|
||||
Role: orgUsersReaderRole,
|
||||
Grants: []string{RoleGrafanaAdmin, string(models.ROLE_ADMIN)},
|
||||
Grants: []string{RoleGrafanaAdmin, string(org.RoleAdmin)},
|
||||
}
|
||||
orgUsersWriter := RoleRegistration{
|
||||
Role: orgUsersWriterRole,
|
||||
Grants: []string{RoleGrafanaAdmin, string(models.ROLE_ADMIN)},
|
||||
Grants: []string{RoleGrafanaAdmin, string(org.RoleAdmin)},
|
||||
}
|
||||
settingsReader := RoleRegistration{
|
||||
Role: SettingsReaderRole,
|
||||
@@ -232,7 +232,7 @@ func ValidateFixedRole(role RoleDTO) error {
|
||||
// ValidateBuiltInRoles errors when a built-in role does not match expected pattern
|
||||
func ValidateBuiltInRoles(builtInRoles []string) error {
|
||||
for _, br := range builtInRoles {
|
||||
if !models.RoleType(br).IsValid() && br != RoleGrafanaAdmin {
|
||||
if !org.RoleType(br).IsValid() && br != RoleGrafanaAdmin {
|
||||
return fmt.Errorf("'%s' %w", br, ErrInvalidBuiltinRole)
|
||||
}
|
||||
}
|
||||
@@ -262,34 +262,34 @@ func (m *RegistrationList) Range(f func(registration RoleRegistration) bool) {
|
||||
|
||||
func BuildBasicRoleDefinitions() map[string]*RoleDTO {
|
||||
return map[string]*RoleDTO{
|
||||
string(models.ROLE_ADMIN): {
|
||||
string(org.RoleAdmin): {
|
||||
Name: BasicRolePrefix + "admin",
|
||||
UID: BasicRoleUIDPrefix + "admin",
|
||||
OrgID: GlobalOrgID,
|
||||
Version: 1,
|
||||
DisplayName: string(models.ROLE_ADMIN),
|
||||
DisplayName: string(org.RoleAdmin),
|
||||
Description: "Admin role",
|
||||
Group: "Basic",
|
||||
Permissions: []Permission{},
|
||||
Hidden: true,
|
||||
},
|
||||
string(models.ROLE_EDITOR): {
|
||||
string(org.RoleEditor): {
|
||||
Name: BasicRolePrefix + "editor",
|
||||
UID: BasicRoleUIDPrefix + "editor",
|
||||
OrgID: GlobalOrgID,
|
||||
Version: 1,
|
||||
DisplayName: string(models.ROLE_EDITOR),
|
||||
DisplayName: string(org.RoleEditor),
|
||||
Description: "Editor role",
|
||||
Group: "Basic",
|
||||
Permissions: []Permission{},
|
||||
Hidden: true,
|
||||
},
|
||||
string(models.ROLE_VIEWER): {
|
||||
string(org.RoleViewer): {
|
||||
Name: BasicRolePrefix + "viewer",
|
||||
UID: BasicRoleUIDPrefix + "viewer",
|
||||
OrgID: GlobalOrgID,
|
||||
Version: 1,
|
||||
DisplayName: string(models.ROLE_VIEWER),
|
||||
DisplayName: string(org.RoleViewer),
|
||||
Description: "Viewer role",
|
||||
Group: "Basic",
|
||||
Permissions: []Permission{},
|
||||
|
||||
Reference in New Issue
Block a user