RBAC: Allow plugins to use scoped actions (#90945)
Co-authored-by: gamab <gabriel.mabille@grafana.com>
This commit is contained in:
committed by
Kevin Minehart
parent
beac3bdbcb
commit
9cdba084a9
@@ -19,11 +19,11 @@ import (
|
||||
glog "github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/oauthtoken"
|
||||
pluginac "github.com/grafana/grafana/pkg/services/pluginsintegration/pluginaccesscontrol"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
"github.com/grafana/grafana/pkg/util/proxyutil"
|
||||
@@ -341,12 +341,12 @@ func (proxy *DataSourceProxy) hasAccessToRoute(route *plugins.Route) bool {
|
||||
ctxLogger := logger.FromContext(proxy.ctx.Req.Context())
|
||||
useRBAC := proxy.features.IsEnabled(proxy.ctx.Req.Context(), featuremgmt.FlagAccessControlOnCall) && route.ReqAction != ""
|
||||
if useRBAC {
|
||||
routeEval := accesscontrol.EvalPermission(route.ReqAction)
|
||||
ok := routeEval.Evaluate(proxy.ctx.GetPermissions())
|
||||
if !ok {
|
||||
routeEval := pluginac.GetDataSourceRouteEvaluator(proxy.ds.UID, route.ReqAction)
|
||||
hasAccess := routeEval.Evaluate(proxy.ctx.GetPermissions())
|
||||
if !hasAccess {
|
||||
ctxLogger.Debug("plugin route is covered by RBAC, user doesn't have access", "route", proxy.ctx.Req.URL.Path, "action", route.ReqAction, "path", route.Path, "method", route.Method)
|
||||
}
|
||||
return ok
|
||||
return hasAccess
|
||||
}
|
||||
if route.ReqRole.IsValid() {
|
||||
if hasUserRole := proxy.ctx.HasUserRole(route.ReqRole); !hasUserRole {
|
||||
|
||||
Reference in New Issue
Block a user