grafana/pkg/infra/usagestats/service/accesscontrol.go
Alexander Zobnin 1fdd3767f1
RBAC: Add permission to get usage report preview (#61570)
* AccessControl: Protect usage report preview endpoint

* Fix role display name

* Change action name

* Fix imports
2023-01-18 16:07:36 +01:00

31 lines
692 B
Go

package service
import (
"github.com/grafana/grafana/pkg/services/accesscontrol"
)
const (
ActionRead = "server.usagestats.report:read"
)
var (
usagestatsReaderRole = accesscontrol.RoleDTO{
Name: "fixed:usagestats:reader",
DisplayName: "Usage stats report reader",
Description: "View usage statistics report",
Group: "Statistics",
Permissions: []accesscontrol.Permission{
{Action: ActionRead},
},
}
)
func declareFixedRoles(ac accesscontrol.Service) error {
usagestatsReader := accesscontrol.RoleRegistration{
Role: usagestatsReaderRole,
Grants: []string{string(accesscontrol.RoleGrafanaAdmin)},
}
return ac.DeclareFixedRoles(usagestatsReader)
}