mirror of
https://github.com/grafana/grafana.git
synced 2024-11-28 03:34:15 -06:00
RBAC: Move service and evaluator to acimpl package (#54714)
* RBAC: Move access control evaluator to acimpl package * RBAC: Move service to acimpl package
This commit is contained in:
parent
73eb1f047a
commit
ff35e35ce0
@ -22,6 +22,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/database"
|
||||
accesscontrolmock "github.com/grafana/grafana/pkg/services/accesscontrol/mock"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/ossaccesscontrol"
|
||||
@ -378,9 +379,9 @@ func setupHTTPServerWithCfgDb(
|
||||
acService = acmock
|
||||
} else {
|
||||
var err error
|
||||
acService, err = ossaccesscontrol.ProvideService(cfg, database.ProvideService(db), routeRegister)
|
||||
acService, err = acimpl.ProvideService(cfg, database.ProvideService(db), routeRegister)
|
||||
require.NoError(t, err)
|
||||
ac = ossaccesscontrol.ProvideAccessControl(cfg, acService)
|
||||
ac = acimpl.ProvideAccessControl(cfg, acService)
|
||||
}
|
||||
|
||||
teamPermissionService, err := ossaccesscontrol.ProvideTeamPermissions(cfg, routeRegister, db, ac, license, acService)
|
||||
|
@ -43,6 +43,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins/plugincontext"
|
||||
"github.com/grafana/grafana/pkg/plugins/repo"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/ossaccesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/alerting"
|
||||
"github.com/grafana/grafana/pkg/services/auth"
|
||||
@ -334,8 +335,8 @@ var wireSet = wire.NewSet(
|
||||
wire.Bind(new(db.DB), new(*sqlstore.SQLStore)),
|
||||
prefimpl.ProvideService,
|
||||
opentsdb.ProvideService,
|
||||
ossaccesscontrol.ProvideAccessControl,
|
||||
wire.Bind(new(accesscontrol.AccessControl), new(*ossaccesscontrol.AccessControl)),
|
||||
acimpl.ProvideAccessControl,
|
||||
wire.Bind(new(accesscontrol.AccessControl), new(*acimpl.AccessControl)),
|
||||
)
|
||||
|
||||
func Initialize(cfg *setting.Cfg) (Runner, error) {
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/server/backgroundsvcs"
|
||||
"github.com/grafana/grafana/pkg/server/usagestatssvcs"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||
acdb "github.com/grafana/grafana/pkg/services/accesscontrol/database"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/ossaccesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/auth"
|
||||
@ -51,9 +52,9 @@ var wireExtsSet = wire.NewSet(
|
||||
auth.ProvideUserAuthTokenService,
|
||||
wire.Bind(new(models.UserTokenService), new(*auth.UserAuthTokenService)),
|
||||
wire.Bind(new(models.UserTokenBackgroundService), new(*auth.UserAuthTokenService)),
|
||||
ossaccesscontrol.ProvideService,
|
||||
wire.Bind(new(accesscontrol.Service), new(*ossaccesscontrol.Service)),
|
||||
wire.Bind(new(accesscontrol.RoleRegistry), new(*ossaccesscontrol.Service)),
|
||||
acimpl.ProvideService,
|
||||
wire.Bind(new(accesscontrol.Service), new(*acimpl.Service)),
|
||||
wire.Bind(new(accesscontrol.RoleRegistry), new(*acimpl.Service)),
|
||||
thumbs.ProvideCrawlerAuthSetupService,
|
||||
wire.Bind(new(thumbs.CrawlerAuthSetupService), new(*thumbs.OSSCrawlerAuthSetupService)),
|
||||
validations.ProvideValidator,
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/infra/serverlock"
|
||||
"github.com/grafana/grafana/pkg/registry"
|
||||
"github.com/grafana/grafana/pkg/server/backgroundsvcs"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/ossaccesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||
"github.com/grafana/grafana/pkg/services/secrets/kvstore/migrations"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore"
|
||||
"github.com/grafana/grafana/pkg/services/user/usertest"
|
||||
@ -55,7 +55,7 @@ func testServer(t *testing.T, services ...registry.BackgroundService) *Server {
|
||||
secretMigrationService := &migrations.SecretMigrationServiceImpl{
|
||||
ServerLockService: serverLockService,
|
||||
}
|
||||
s, err := newServer(Options{}, setting.NewCfg(), nil, &ossaccesscontrol.Service{}, nil, backgroundsvcs.NewBackgroundServiceRegistry(services...), secretMigrationService, usertest.NewUserServiceFake(), nil)
|
||||
s, err := newServer(Options{}, setting.NewCfg(), nil, &acimpl.Service{}, nil, backgroundsvcs.NewBackgroundServiceRegistry(services...), secretMigrationService, usertest.NewUserServiceFake(), nil)
|
||||
require.NoError(t, err)
|
||||
// Required to skip configuration initialization that causes
|
||||
// DI errors in this test.
|
||||
|
@ -6,6 +6,7 @@ package server
|
||||
import (
|
||||
"github.com/google/wire"
|
||||
sdkhttpclient "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"
|
||||
|
||||
"github.com/grafana/grafana/pkg/services/auth"
|
||||
"github.com/grafana/grafana/pkg/services/playlist/playlistimpl"
|
||||
"github.com/grafana/grafana/pkg/services/store/sanitizer"
|
||||
@ -44,6 +45,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/plugins/plugincontext"
|
||||
"github.com/grafana/grafana/pkg/plugins/repo"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/ossaccesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/alerting"
|
||||
"github.com/grafana/grafana/pkg/services/apikey/apikeyimpl"
|
||||
@ -335,8 +337,8 @@ var wireBasicSet = wire.NewSet(
|
||||
secretsMigrations.ProvideSecretMigrationService,
|
||||
wire.Bind(new(secretsMigrations.SecretMigrationService), new(*secretsMigrations.SecretMigrationServiceImpl)),
|
||||
userauthimpl.ProvideService,
|
||||
ossaccesscontrol.ProvideAccessControl,
|
||||
wire.Bind(new(accesscontrol.AccessControl), new(*ossaccesscontrol.AccessControl)),
|
||||
acimpl.ProvideAccessControl,
|
||||
wire.Bind(new(accesscontrol.AccessControl), new(*acimpl.AccessControl)),
|
||||
)
|
||||
|
||||
var wireSet = wire.NewSet(
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/server/backgroundsvcs"
|
||||
"github.com/grafana/grafana/pkg/server/usagestatssvcs"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||
acdb "github.com/grafana/grafana/pkg/services/accesscontrol/database"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/ossaccesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/auth"
|
||||
@ -46,9 +47,9 @@ var wireExtsBasicSet = wire.NewSet(
|
||||
wire.Bind(new(models.Licensing), new(*licensing.OSSLicensingService)),
|
||||
setting.ProvideProvider,
|
||||
wire.Bind(new(setting.Provider), new(*setting.OSSImpl)),
|
||||
ossaccesscontrol.ProvideService,
|
||||
wire.Bind(new(accesscontrol.RoleRegistry), new(*ossaccesscontrol.Service)),
|
||||
wire.Bind(new(accesscontrol.Service), new(*ossaccesscontrol.Service)),
|
||||
acimpl.ProvideService,
|
||||
wire.Bind(new(accesscontrol.RoleRegistry), new(*acimpl.Service)),
|
||||
wire.Bind(new(accesscontrol.Service), new(*acimpl.Service)),
|
||||
thumbs.ProvideCrawlerAuthSetupService,
|
||||
wire.Bind(new(thumbs.CrawlerAuthSetupService), new(*thumbs.OSSCrawlerAuthSetupService)),
|
||||
validations.ProvideValidator,
|
||||
|
@ -1,4 +1,4 @@
|
||||
package ossaccesscontrol
|
||||
package acimpl
|
||||
|
||||
import (
|
||||
"context"
|
@ -1,4 +1,4 @@
|
||||
package ossaccesscontrol
|
||||
package acimpl
|
||||
|
||||
import (
|
||||
"context"
|
@ -1,4 +1,4 @@
|
||||
package ossaccesscontrol
|
||||
package acimpl
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/infra/metrics"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/api"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/ossaccesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
@ -58,7 +59,7 @@ func (s *Service) GetUsageStats(_ context.Context) map[string]interface{} {
|
||||
}
|
||||
|
||||
var actionsToFetch = append(
|
||||
TeamAdminActions, append(DashboardAdminActions, FolderAdminActions...)...,
|
||||
ossaccesscontrol.TeamAdminActions, append(ossaccesscontrol.DashboardAdminActions, ossaccesscontrol.FolderAdminActions...)...,
|
||||
)
|
||||
|
||||
// GetUserPermissions returns user permissions based on built-in roles
|
@ -1,4 +1,4 @@
|
||||
package ossaccesscontrol
|
||||
package acimpl
|
||||
|
||||
import (
|
||||
"context"
|
@ -16,8 +16,8 @@ import (
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/database"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/ossaccesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/contexthandler/ctxkey"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
@ -55,9 +55,9 @@ func setupTestServer(
|
||||
}
|
||||
|
||||
var err error
|
||||
acService, err := ossaccesscontrol.ProvideService(cfg, database.ProvideService(db), rr)
|
||||
acService, err := acimpl.ProvideService(cfg, database.ProvideService(db), rr)
|
||||
require.NoError(t, err)
|
||||
ac := ossaccesscontrol.ProvideAccessControl(cfg, acService)
|
||||
ac := acimpl.ProvideAccessControl(cfg, acService)
|
||||
|
||||
// build mux
|
||||
m := web.New()
|
||||
|
Loading…
Reference in New Issue
Block a user