Access control: Add a role for provisioning admins (#33787)

This commit is contained in:
Vardan Torosyan 2021-05-10 11:46:42 +02:00 committed by GitHub
parent baf80dad82
commit 1d15686bdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -42,6 +42,10 @@ func (p RoleDTO) Role() Role {
const ( const (
// Permission actions // Permission actions
// Actions
// Provisioning actions
ActionProvisioningReload = "provisioning:reload"
// Users actions // Users actions
ActionUsersRead = "users:read" ActionUsersRead = "users:read"
ActionUsersWrite = "users:write" ActionUsersWrite = "users:write"
@ -80,6 +84,9 @@ const (
ScopeUsersSelf = "users:self" ScopeUsersSelf = "users:self"
ScopeUsersAll = "users:*" ScopeUsersAll = "users:*"
// Services Scopes
ScopeServicesAll = "service:*"
) )
const RoleGrafanaAdmin = "Grafana Admin" const RoleGrafanaAdmin = "Grafana Admin"

View File

@ -124,6 +124,17 @@ var usersAdminEditRole = RoleDTO{
}), }),
} }
var provisioningAdminRole = RoleDTO{
Name: provisioningAdmin,
Version: 1,
Permissions: []Permission{
{
Action: ActionProvisioningReload,
Scope: ScopeServicesAll,
},
},
}
// PredefinedRoles provides a map of permission sets/roles which can be // PredefinedRoles provides a map of permission sets/roles which can be
// assigned to a set of users. When adding a new resource protected by // assigned to a set of users. When adding a new resource protected by
// Grafana access control the default permissions should be added to a // Grafana access control the default permissions should be added to a
@ -139,6 +150,8 @@ var PredefinedRoles = map[string]RoleDTO{
ldapAdminRead: ldapAdminReadRole, ldapAdminRead: ldapAdminReadRole,
ldapAdminEdit: ldapAdminEditRole, ldapAdminEdit: ldapAdminEditRole,
provisioningAdmin: provisioningAdminRole,
} }
const ( const (
@ -150,6 +163,8 @@ const (
ldapAdminEdit = "grafana:roles:ldap:admin:edit" ldapAdminEdit = "grafana:roles:ldap:admin:edit"
ldapAdminRead = "grafana:roles:ldap:admin:read" ldapAdminRead = "grafana:roles:ldap:admin:read"
provisioningAdmin = "grafana:roles:provisioning:admin"
) )
// PredefinedRoleGrants specifies which organization roles are assigned // PredefinedRoleGrants specifies which organization roles are assigned
@ -158,6 +173,7 @@ var PredefinedRoleGrants = map[string][]string{
RoleGrafanaAdmin: { RoleGrafanaAdmin: {
ldapAdminEdit, ldapAdminEdit,
ldapAdminRead, ldapAdminRead,
provisioningAdmin,
usersAdminEdit, usersAdminEdit,
usersAdminRead, usersAdminRead,
usersOrgEdit, usersOrgEdit,