mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
LibraryPanels/RBAC: Fix issue where folder scopes weren't being correctly inherited (#82700)
This commit is contained in:
parent
7b415cf79e
commit
82e3e2e558
@ -21,6 +21,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/org"
|
||||
"github.com/grafana/grafana/pkg/services/search"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/migrator"
|
||||
"github.com/grafana/grafana/pkg/services/sqlstore/searchstore"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
@ -283,7 +284,7 @@ func (l *LibraryElementService) getLibraryElements(c context.Context, store db.D
|
||||
builder := db.NewSqlBuilder(cfg, features, store.GetDialect(), recursiveQueriesAreSupported)
|
||||
builder.Write(selectLibraryElementDTOWithMeta)
|
||||
builder.Write(", ? as folder_name ", cmd.FolderName)
|
||||
builder.Write(", '' as folder_uid ")
|
||||
builder.Write(", COALESCE((SELECT folder.uid FROM folder WHERE folder.id = le.folder_id), '') as folder_uid ")
|
||||
builder.Write(getFromLibraryElementDTOWithMeta(store.GetDialect()))
|
||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryElements).Inc()
|
||||
// nolint:staticcheck
|
||||
@ -295,7 +296,7 @@ func (l *LibraryElementService) getLibraryElements(c context.Context, store db.D
|
||||
builder.Write(getFromLibraryElementDTOWithMeta(store.GetDialect()))
|
||||
builder.Write(" INNER JOIN dashboard AS dashboard on le.folder_id = dashboard.id AND le.folder_id <> 0")
|
||||
writeParamSelectorSQL(&builder, params...)
|
||||
builder.WriteDashboardPermissionFilter(signedInUser, dashboardaccess.PERMISSION_VIEW, "")
|
||||
builder.WriteDashboardPermissionFilter(signedInUser, dashboardaccess.PERMISSION_VIEW, searchstore.TypeFolder)
|
||||
builder.Write(` OR dashboard.id=0`)
|
||||
if err := session.SQL(builder.GetSQLString(), builder.GetParams()...).Find(&libraryElements); err != nil {
|
||||
return err
|
||||
@ -321,11 +322,15 @@ func (l *LibraryElementService) getLibraryElements(c context.Context, store db.D
|
||||
}
|
||||
|
||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryElements).Inc()
|
||||
folderUID := libraryElement.FolderUID
|
||||
if libraryElement.FolderID == 0 { // nolint:staticcheck
|
||||
folderUID = ac.GeneralFolderUID
|
||||
}
|
||||
leDtos[i] = model.LibraryElementDTO{
|
||||
ID: libraryElement.ID,
|
||||
OrgID: libraryElement.OrgID,
|
||||
FolderID: libraryElement.FolderID, // nolint:staticcheck
|
||||
FolderUID: libraryElement.FolderUID,
|
||||
FolderUID: folderUID,
|
||||
UID: libraryElement.UID,
|
||||
Name: libraryElement.Name,
|
||||
Kind: libraryElement.Kind,
|
||||
|
Loading…
Reference in New Issue
Block a user