2022-12-20 10:13:37 +00:00
|
|
|
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: "Support bundle reader",
|
|
|
|
|
Description: "List and download support bundles",
|
|
|
|
|
Group: "Support bundles",
|
|
|
|
|
Permissions: []accesscontrol.Permission{
|
|
|
|
|
{Action: ActionRead},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bundleWriterRole = accesscontrol.RoleDTO{
|
|
|
|
|
Name: "fixed:support.bundles:writer",
|
|
|
|
|
DisplayName: "Support bundle writer",
|
|
|
|
|
Description: "Create, delete, list and download support bundles",
|
|
|
|
|
Group: "Support bundles",
|
|
|
|
|
Permissions: []accesscontrol.Permission{
|
|
|
|
|
{Action: ActionRead},
|
|
|
|
|
{Action: ActionCreate},
|
|
|
|
|
{Action: ActionDelete},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
2023-01-20 08:59:15 +00:00
|
|
|
func (s *Service) declareFixedRoles(ac accesscontrol.Service) error {
|
|
|
|
|
grants := []string{string(org.RoleAdmin), accesscontrol.RoleGrafanaAdmin}
|
|
|
|
|
if s.serverAdminOnly {
|
|
|
|
|
grants = []string{accesscontrol.RoleGrafanaAdmin}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-20 10:13:37 +00:00
|
|
|
bundleReader := accesscontrol.RoleRegistration{
|
|
|
|
|
Role: bundleReaderRole,
|
2023-01-20 08:59:15 +00:00
|
|
|
Grants: grants,
|
2022-12-20 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
bundleWriter := accesscontrol.RoleRegistration{
|
|
|
|
|
Role: bundleWriterRole,
|
2023-01-20 08:59:15 +00:00
|
|
|
Grants: grants,
|
2022-12-20 10:13:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ac.DeclareFixedRoles(bundleWriter, bundleReader)
|
|
|
|
|
}
|