mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 10:03:33 -06:00
* 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
43 lines
999 B
Go
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
|
|
}
|