grafana/pkg/services/serviceaccounts/manager/roles.go
J Guerreiro 8c49e96439
ServiceAccounts: Add token view for Service Accounts (#45013)
* fix SA creation scope

* add writer action to SA fixed role

* ServiceAccounts: Add token table to SA detail page

* ServiceAccounts: Allow deletion of tokens from token table

* refactor service account page

* avoid using store for delete
2022-02-08 11:35:15 +00:00

43 lines
999 B
Go

package manager
import (
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/serviceaccounts"
)
func RegisterRoles(ac accesscontrol.AccessControl) error {
role := accesscontrol.RoleRegistration{
Role: accesscontrol.RoleDTO{
Version: 3,
Name: "fixed:serviceaccounts:writer",
DisplayName: "Service accounts writer",
Description: "Create, delete, read, or query service accounts.",
Group: "Service accounts",
Permissions: []accesscontrol.Permission{
{
Action: serviceaccounts.ActionRead,
Scope: serviceaccounts.ScopeAll,
},
{
Action: serviceaccounts.ActionWrite,
Scope: serviceaccounts.ScopeAll,
},
{
Action: serviceaccounts.ActionCreate,
},
{
Action: serviceaccounts.ActionDelete,
Scope: serviceaccounts.ScopeAll,
},
},
},
Grants: []string{"Admin"},
}
if err := ac.DeclareFixedRoles(role); err != nil {
return err
}
return nil
}