Files
Cory Forseth 4caa9853cb Authorization: Add group to role DisplayName to make filtered list more clear (#102950)
* 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
2025-04-08 09:15:03 -05:00

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)
}