mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* wip * implement role middleware drop * remove not implement feature * change grants based on config * Update pkg/services/supportbundles/supportbundlesimpl/models.go Co-authored-by: Ieva <ieva.vasiljeva@grafana.com> Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
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: "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},
|
|
},
|
|
}
|
|
)
|
|
|
|
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)
|
|
}
|