mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 19:00:54 -06:00
0de66a8099
* remove use of SignedInUserCopies * add extra safety to not cross assign permissions unwind circular dependency dashboardacl->dashboardaccess fix missing import * correctly set teams for permissions * fix missing inits * nit: check err * exit early for api keys
33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
package dashboardaccess
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
type PermissionType int
|
|
|
|
const (
|
|
PERMISSION_VIEW PermissionType = 1 << iota
|
|
PERMISSION_EDIT
|
|
PERMISSION_ADMIN
|
|
)
|
|
|
|
func (p PermissionType) String() string {
|
|
names := map[int]string{
|
|
int(PERMISSION_VIEW): "View",
|
|
int(PERMISSION_EDIT): "Edit",
|
|
int(PERMISSION_ADMIN): "Admin",
|
|
}
|
|
return names[int(p)]
|
|
}
|
|
|
|
// Typed errors
|
|
var (
|
|
ErrDashboardACLInfoMissing = errors.New("user id and team id cannot both be empty for a dashboard permission")
|
|
ErrDashboardPermissionDashboardEmpty = errors.New("dashboard id must be greater than zero for a dashboard permission")
|
|
ErrFolderACLInfoMissing = errors.New("user id and team id cannot both be empty for a folder permission")
|
|
ErrFolderPermissionFolderEmpty = errors.New("folder id must be greater than zero for a folder permission")
|
|
ErrPermissionsWithRoleNotAllowed = errors.New("permissions cannot have both a user and team")
|
|
ErrPermissionsWithUserAndTeamNotAllowed = errors.New("team and user permissions cannot have an associated role")
|
|
)
|