mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 23:22:32 +08:00

* add group to role DisplayName to make searching easier * clean up more role names; add filtered display text when fetching * pass filter state into role menu to decide how to display role name * prop name better describes what it does
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package supportbundlesimpl
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
|
"github.com/grafana/grafana/pkg/services/org"
|
|
)
|
|
|
|
const (
|
|
ActionRead = "support.bundles:read"
|
|
ActionCreate = "support.bundles:create"
|
|
ActionDelete = "support.bundles:delete"
|
|
)
|
|
|
|
var (
|
|
bundleReaderRole = accesscontrol.RoleDTO{
|
|
Name: "fixed:support.bundles:reader",
|
|
DisplayName: "Reader",
|
|
Description: "List and download support bundles",
|
|
Group: "Support bundles",
|
|
Permissions: []accesscontrol.Permission{
|
|
{Action: ActionRead},
|
|
},
|
|
}
|
|
|
|
bundleWriterRole = accesscontrol.RoleDTO{
|
|
Name: "fixed:support.bundles:writer",
|
|
DisplayName: "Writer",
|
|
Description: "Create, delete, list and download support bundles",
|
|
Group: "Support bundles",
|
|
Permissions: []accesscontrol.Permission{
|
|
{Action: ActionRead},
|
|
{Action: ActionCreate},
|
|
{Action: ActionDelete},
|
|
},
|
|
}
|
|
)
|
|
|
|
func (s *Service) declareFixedRoles(ac accesscontrol.Service) error {
|
|
grants := []string{string(org.RoleAdmin), accesscontrol.RoleGrafanaAdmin}
|
|
if s.serverAdminOnly {
|
|
grants = []string{accesscontrol.RoleGrafanaAdmin}
|
|
}
|
|
|
|
bundleReader := accesscontrol.RoleRegistration{
|
|
Role: bundleReaderRole,
|
|
Grants: grants,
|
|
}
|
|
bundleWriter := accesscontrol.RoleRegistration{
|
|
Role: bundleWriterRole,
|
|
Grants: grants,
|
|
}
|
|
|
|
return ac.DeclareFixedRoles(bundleWriter, bundleReader)
|
|
}
|