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:
+18
-17
@@ -8,6 +8,7 @@ import (
|
||||
ac "github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/services/serviceaccounts"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/tsdb/grafanads"
|
||||
@@ -74,11 +75,11 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
},
|
||||
},
|
||||
},
|
||||
Grants: []string{string(models.ROLE_EDITOR)},
|
||||
Grants: []string{string(org.RoleEditor)},
|
||||
}
|
||||
|
||||
if setting.ViewersCanEdit {
|
||||
datasourcesExplorerRole.Grants = append(datasourcesExplorerRole.Grants, string(models.ROLE_VIEWER))
|
||||
datasourcesExplorerRole.Grants = append(datasourcesExplorerRole.Grants, string(org.RoleViewer))
|
||||
}
|
||||
|
||||
datasourcesReaderRole := ac.RoleRegistration{
|
||||
@@ -98,7 +99,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
},
|
||||
},
|
||||
},
|
||||
Grants: []string{string(models.ROLE_ADMIN)},
|
||||
Grants: []string{string(org.RoleAdmin)},
|
||||
}
|
||||
|
||||
builtInDatasourceReader := ac.RoleRegistration{
|
||||
@@ -119,12 +120,12 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
},
|
||||
Hidden: true,
|
||||
},
|
||||
Grants: []string{string(models.ROLE_VIEWER)},
|
||||
Grants: []string{string(org.RoleViewer)},
|
||||
}
|
||||
|
||||
// when running oss or enterprise without a license all users should be able to query data sources
|
||||
if !hs.License.FeatureEnabled("accesscontrol.enforcement") {
|
||||
datasourcesReaderRole.Grants = []string{string(models.ROLE_VIEWER)}
|
||||
datasourcesReaderRole.Grants = []string{string(org.RoleViewer)}
|
||||
}
|
||||
|
||||
datasourcesWriterRole := ac.RoleRegistration{
|
||||
@@ -147,7 +148,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
},
|
||||
}),
|
||||
},
|
||||
Grants: []string{string(models.ROLE_ADMIN)},
|
||||
Grants: []string{string(org.RoleAdmin)},
|
||||
}
|
||||
|
||||
datasourcesIdReaderRole := ac.RoleRegistration{
|
||||
@@ -163,7 +164,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
},
|
||||
},
|
||||
},
|
||||
Grants: []string{string(models.ROLE_VIEWER)},
|
||||
Grants: []string{string(org.RoleViewer)},
|
||||
}
|
||||
|
||||
apikeyReaderRole := ac.RoleRegistration{
|
||||
@@ -179,7 +180,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
},
|
||||
},
|
||||
},
|
||||
Grants: []string{string(models.ROLE_ADMIN)},
|
||||
Grants: []string{string(org.RoleAdmin)},
|
||||
}
|
||||
|
||||
apikeyWriterRole := ac.RoleRegistration{
|
||||
@@ -198,7 +199,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
},
|
||||
}),
|
||||
},
|
||||
Grants: []string{string(models.ROLE_ADMIN)},
|
||||
Grants: []string{string(org.RoleAdmin)},
|
||||
}
|
||||
|
||||
orgReaderRole := ac.RoleRegistration{
|
||||
@@ -212,7 +213,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
{Action: ActionOrgsQuotasRead},
|
||||
},
|
||||
},
|
||||
Grants: []string{string(models.ROLE_VIEWER), ac.RoleGrafanaAdmin},
|
||||
Grants: []string{string(org.RoleViewer), ac.RoleGrafanaAdmin},
|
||||
}
|
||||
|
||||
orgWriterRole := ac.RoleRegistration{
|
||||
@@ -227,7 +228,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
{Action: ActionOrgsPreferencesWrite},
|
||||
}),
|
||||
},
|
||||
Grants: []string{string(models.ROLE_ADMIN)},
|
||||
Grants: []string{string(org.RoleAdmin)},
|
||||
}
|
||||
|
||||
orgMaintainerRole := ac.RoleRegistration{
|
||||
@@ -246,9 +247,9 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
Grants: []string{string(ac.RoleGrafanaAdmin)},
|
||||
}
|
||||
|
||||
teamCreatorGrants := []string{string(models.ROLE_ADMIN)}
|
||||
teamCreatorGrants := []string{string(org.RoleAdmin)}
|
||||
if hs.Cfg.EditorsCanAdmin {
|
||||
teamCreatorGrants = append(teamCreatorGrants, string(models.ROLE_EDITOR))
|
||||
teamCreatorGrants = append(teamCreatorGrants, string(org.RoleEditor))
|
||||
}
|
||||
teamsCreatorRole := ac.RoleRegistration{
|
||||
Role: ac.RoleDTO{
|
||||
@@ -279,7 +280,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
{Action: ac.ActionTeamsWrite, Scope: ac.ScopeTeamsAll},
|
||||
},
|
||||
},
|
||||
Grants: []string{string(models.ROLE_ADMIN)},
|
||||
Grants: []string{string(org.RoleAdmin)},
|
||||
}
|
||||
|
||||
annotationsReaderRole := ac.RoleRegistration{
|
||||
@@ -292,7 +293,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
{Action: ac.ActionAnnotationsRead, Scope: ac.ScopeAnnotationsAll},
|
||||
},
|
||||
},
|
||||
Grants: []string{string(models.ROLE_VIEWER)},
|
||||
Grants: []string{string(org.RoleViewer)},
|
||||
}
|
||||
|
||||
dashboardAnnotationsWriterRole := ac.RoleRegistration{
|
||||
@@ -307,7 +308,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
{Action: ac.ActionAnnotationsWrite, Scope: ac.ScopeAnnotationsTypeDashboard},
|
||||
},
|
||||
},
|
||||
Grants: []string{string(models.ROLE_VIEWER)},
|
||||
Grants: []string{string(org.RoleViewer)},
|
||||
}
|
||||
|
||||
annotationsWriterRole := ac.RoleRegistration{
|
||||
@@ -322,7 +323,7 @@ func (hs *HTTPServer) declareFixedRoles() error {
|
||||
{Action: ac.ActionAnnotationsWrite, Scope: ac.ScopeAnnotationsAll},
|
||||
},
|
||||
},
|
||||
Grants: []string{string(models.ROLE_EDITOR)},
|
||||
Grants: []string{string(org.RoleEditor)},
|
||||
}
|
||||
|
||||
dashboardsCreatorRole := ac.RoleRegistration{
|
||||
|
||||
Reference in New Issue
Block a user