2022-03-09 10:57:50 -06:00
|
|
|
package datasources
|
|
|
|
|
|
|
|
import "github.com/grafana/grafana/pkg/services/accesscontrol"
|
|
|
|
|
|
|
|
const (
|
2022-03-24 06:21:26 -05:00
|
|
|
ScopeRoot = "datasources"
|
|
|
|
ScopePrefix = ScopeRoot + ":uid:"
|
2022-03-09 10:57:50 -06:00
|
|
|
|
2022-03-16 09:11:03 -05:00
|
|
|
ActionRead = "datasources:read"
|
|
|
|
ActionQuery = "datasources:query"
|
|
|
|
ActionCreate = "datasources:create"
|
|
|
|
ActionWrite = "datasources:write"
|
|
|
|
ActionDelete = "datasources:delete"
|
|
|
|
ActionIDRead = "datasources.id:read"
|
|
|
|
ActionPermissionsRead = "datasources.permissions:read"
|
|
|
|
ActionPermissionsWrite = "datasources.permissions:write"
|
2022-03-09 10:57:50 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2022-03-16 09:11:03 -05:00
|
|
|
ScopeID = accesscontrol.Scope("datasources", "id", accesscontrol.Parameter(":datasourceId"))
|
|
|
|
ScopeAll = accesscontrol.GetResourceAllScope(ScopeRoot)
|
|
|
|
ScopeProvider = accesscontrol.NewScopeProvider(ScopeRoot)
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// ConfigurationPageAccess is used to protect the "Configure > Data sources" tab access
|
|
|
|
ConfigurationPageAccess = accesscontrol.EvalAll(
|
|
|
|
accesscontrol.EvalPermission(ActionRead),
|
|
|
|
accesscontrol.EvalAny(
|
|
|
|
accesscontrol.EvalPermission(ActionCreate),
|
|
|
|
accesscontrol.EvalPermission(ActionDelete),
|
|
|
|
accesscontrol.EvalPermission(ActionWrite),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewPageAccess is used to protect the "Configure > Data sources > New" page access
|
|
|
|
NewPageAccess = accesscontrol.EvalAll(
|
|
|
|
accesscontrol.EvalPermission(ActionRead),
|
|
|
|
accesscontrol.EvalPermission(ActionCreate),
|
|
|
|
)
|
|
|
|
|
|
|
|
// EditPageAccess is used to protect the "Configure > Data sources > Edit" page access
|
|
|
|
EditPageAccess = accesscontrol.EvalAll(
|
|
|
|
accesscontrol.EvalPermission(ActionRead),
|
|
|
|
accesscontrol.EvalPermission(ActionWrite),
|
|
|
|
)
|
2022-03-09 10:57:50 -06:00
|
|
|
)
|