Access control: Modify dashboard/folder resolvers so that return also the inherited scopes (#62025)
* Access Control: Add folder service dependency to the dashboard/folder resolvers * Expose the function fetching parents to folder interface * Add generic prepend utility * Modify dashboard resolvers to return inherited scopes
This commit is contained in:
@@ -51,8 +51,6 @@ func ProvideService(
|
||||
features featuremgmt.FeatureToggles,
|
||||
folderPermissionsService accesscontrol.FolderPermissionsService,
|
||||
) folder.Service {
|
||||
ac.RegisterScopeAttributeResolver(dashboards.NewFolderNameScopeResolver(dashboardStore, folderStore))
|
||||
ac.RegisterScopeAttributeResolver(dashboards.NewFolderIDScopeResolver(dashboardStore, folderStore))
|
||||
store := ProvideStore(db, cfg, features)
|
||||
svr := &Service{
|
||||
cfg: cfg,
|
||||
@@ -68,6 +66,9 @@ func ProvideService(
|
||||
if features.IsEnabled(featuremgmt.FlagNestedFolders) {
|
||||
svr.DBMigration(db)
|
||||
}
|
||||
|
||||
ac.RegisterScopeAttributeResolver(dashboards.NewFolderNameScopeResolver(dashboardStore, folderStore, svr))
|
||||
ac.RegisterScopeAttributeResolver(dashboards.NewFolderIDScopeResolver(dashboardStore, folderStore, svr))
|
||||
return svr
|
||||
}
|
||||
|
||||
@@ -185,6 +186,13 @@ func (s *Service) GetChildren(ctx context.Context, cmd *folder.GetChildrenQuery)
|
||||
return filtered, nil
|
||||
}
|
||||
|
||||
func (s *Service) GetParents(ctx context.Context, q folder.GetParentsQuery) ([]*folder.Folder, error) {
|
||||
if !s.features.IsEnabled(featuremgmt.FlagNestedFolders) {
|
||||
return nil, nil
|
||||
}
|
||||
return s.store.GetParents(ctx, q)
|
||||
}
|
||||
|
||||
func (s *Service) getFolderByID(ctx context.Context, user *user.SignedInUser, id int64, orgID int64) (*folder.Folder, error) {
|
||||
if id == 0 {
|
||||
return &folder.Folder{ID: id, Title: "General"}, nil
|
||||
|
||||
Reference in New Issue
Block a user