RBAC: remove LoadPermissionsMiddleware (#73228)

* PubDash: remove LoadPermissionMiddleware from tests

* RBAC: Remove unused LoadPermission middleware
This commit is contained in:
Karl Persson 2023-08-14 14:07:09 +02:00 committed by GitHub
parent 140624603f
commit 16d24a8429
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 32 deletions

View File

@ -242,22 +242,6 @@ func UseGlobalOrg(c *contextmodel.ReqContext) (int64, error) {
return GlobalOrgID, nil
}
func LoadPermissionsMiddleware(service Service) web.Handler {
return func(c *contextmodel.ReqContext) {
permissions, err := service.GetUserPermissions(c.Req.Context(), c.SignedInUser,
Options{ReloadCache: false})
if err != nil {
c.JsonApiErr(http.StatusForbidden, "", err)
return
}
if c.SignedInUser.Permissions == nil {
c.SignedInUser.Permissions = make(map[int64]map[string][]string)
}
c.SignedInUser.Permissions[c.OrgID] = GroupScopesByAction(permissions)
}
}
// scopeParams holds the parameters used to fill in scope templates
type scopeParams struct {
OrgID int64

View File

@ -17,9 +17,7 @@ import (
"github.com/grafana/grafana/pkg/infra/log"
"github.com/grafana/grafana/pkg/plugins"
pluginFakes "github.com/grafana/grafana/pkg/plugins/manager/fakes"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
"github.com/grafana/grafana/pkg/services/accesscontrol/actest"
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey"
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
"github.com/grafana/grafana/pkg/services/datasources"
@ -47,19 +45,6 @@ func setupTestServer(
// build router to register routes
rr := routing.NewRouteRegister()
var permissions []accesscontrol.Permission
if user != nil && user.Permissions != nil {
for action, scopes := range user.Permissions[user.OrgID] {
for _, scope := range scopes {
permissions = append(permissions, accesscontrol.Permission{
Action: action,
Scope: scope,
})
}
}
}
acService := actest.FakeService{ExpectedPermissions: permissions, ExpectedDisabled: !cfg.RBACEnabled}
ac := acimpl.ProvideAccessControl(cfg)
// build mux
@ -67,7 +52,6 @@ func setupTestServer(
// set initial context
m.Use(contextProvider(&testContext{user}))
m.Use(accesscontrol.LoadPermissionsMiddleware(acService))
// build api, this will mount the routes at the same time if
// featuremgmt.FlagPublicDashboard is enabled