[release-12.0.5] Page limit config for dashboards with visible annotations (#111377)
* Page limit config for dashboards with visible annotations (#110911)
* Page limit config for dashboards with visible annotations
Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
---------
Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
(cherry picked from commit 77fa3333e4)
* Add missing parameter to TestIntegrationAuthorize
Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
---------
Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
Co-authored-by: maicon <maiconscosta@gmail.com>
This commit is contained in:
co-authored by
maicon
parent
3c845fd337
commit
da3717b315
@@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||||
"github.com/grafana/grafana/pkg/services/sqlstore/permissions"
|
"github.com/grafana/grafana/pkg/services/sqlstore/permissions"
|
||||||
"github.com/grafana/grafana/pkg/services/sqlstore/searchstore"
|
"github.com/grafana/grafana/pkg/services/sqlstore/searchstore"
|
||||||
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -28,16 +29,21 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type AuthService struct {
|
type AuthService struct {
|
||||||
db db.DB
|
db db.DB
|
||||||
features featuremgmt.FeatureToggles
|
features featuremgmt.FeatureToggles
|
||||||
dashSvc dashboards.DashboardService
|
dashSvc dashboards.DashboardService
|
||||||
|
searchDashboardsPageLimit int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAuthService(db db.DB, features featuremgmt.FeatureToggles, dashSvc dashboards.DashboardService) *AuthService {
|
func NewAuthService(db db.DB, features featuremgmt.FeatureToggles, dashSvc dashboards.DashboardService, cfg *setting.Cfg) *AuthService {
|
||||||
|
section := cfg.Raw.Section("annotations")
|
||||||
|
searchDashboardsPageLimit := section.Key("search_dashboards_page_limit").MustInt64(1000)
|
||||||
|
|
||||||
return &AuthService{
|
return &AuthService{
|
||||||
db: db,
|
db: db,
|
||||||
features: features,
|
features: features,
|
||||||
dashSvc: dashSvc,
|
dashSvc: dashSvc,
|
||||||
|
searchDashboardsPageLimit: searchDashboardsPageLimit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +148,7 @@ func (authz *AuthService) dashboardsWithVisibleAnnotations(ctx context.Context,
|
|||||||
SignedInUser: query.SignedInUser,
|
SignedInUser: query.SignedInUser,
|
||||||
Page: query.Page,
|
Page: query.Page,
|
||||||
Type: filterType,
|
Type: filterType,
|
||||||
Limit: 1000,
|
Limit: authz.searchDashboardsPageLimit,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ func TestIntegrationAuthorize(t *testing.T) {
|
|||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
u.Permissions = map[int64]map[string][]string{1: tc.permissions}
|
u.Permissions = map[int64]map[string][]string{1: tc.permissions}
|
||||||
testutil.SetupRBACPermission(t, sql, role, u)
|
testutil.SetupRBACPermission(t, sql, role, u)
|
||||||
authz := NewAuthService(sql, featuremgmt.WithFeatures(tc.featureToggle), dashSvc)
|
authz := NewAuthService(sql, featuremgmt.WithFeatures(tc.featureToggle), dashSvc, cfg)
|
||||||
|
|
||||||
query := annotations.ItemQuery{SignedInUser: u, OrgID: 1}
|
query := annotations.ItemQuery{SignedInUser: u, OrgID: 1}
|
||||||
resources, err := authz.Authorize(context.Background(), query)
|
resources, err := authz.Authorize(context.Background(), query)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ func ProvideService(
|
|||||||
return &RepositoryImpl{
|
return &RepositoryImpl{
|
||||||
db: db,
|
db: db,
|
||||||
features: features,
|
features: features,
|
||||||
authZ: accesscontrol.NewAuthService(db, features, dashSvc),
|
authZ: accesscontrol.NewAuthService(db, features, dashSvc, cfg),
|
||||||
reader: read,
|
reader: read,
|
||||||
writer: write,
|
writer: write,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user