mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
LibraryPanels/RBAC: Ignore old folder permission check when deleting/patching lib panel (#88422)
* LibraryPanels/RBAC: Ignore old folder permission check when deleting lib panel * Same for patching
This commit is contained in:
parent
4f999f2b6c
commit
8f45003192
@ -240,9 +240,12 @@ func (l *LibraryElementService) deleteLibraryElement(c context.Context, signedIn
|
||||
return err
|
||||
}
|
||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryElements).Inc()
|
||||
// nolint:staticcheck
|
||||
if err := l.requireEditPermissionsOnFolder(c, signedInUser, element.FolderID); err != nil {
|
||||
return err
|
||||
|
||||
if !l.features.IsEnabled(c, featuremgmt.FlagLibraryPanelRBAC) {
|
||||
// nolint:staticcheck
|
||||
if err := l.requireEditPermissionsOnFolder(c, signedInUser, element.FolderID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Delete any hanging/invalid connections
|
||||
@ -538,17 +541,20 @@ func (l *LibraryElementService) handleFolderIDPatches(ctx context.Context, eleme
|
||||
toFolderID = fromFolderID
|
||||
}
|
||||
|
||||
// FolderID was provided in the PATCH request
|
||||
if toFolderID != -1 && toFolderID != fromFolderID {
|
||||
if err := l.requireEditPermissionsOnFolder(ctx, user, toFolderID); err != nil {
|
||||
if !l.features.IsEnabled(ctx, featuremgmt.FlagLibraryPanelRBAC) {
|
||||
// FolderID was provided in the PATCH request
|
||||
if toFolderID != -1 && toFolderID != fromFolderID {
|
||||
if err := l.requireEditPermissionsOnFolder(ctx, user, toFolderID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Always check permissions for the folder where library element resides
|
||||
if err := l.requireEditPermissionsOnFolder(ctx, user, fromFolderID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Always check permissions for the folder where library element resides
|
||||
if err := l.requireEditPermissionsOnFolder(ctx, user, fromFolderID); err != nil {
|
||||
return err
|
||||
}
|
||||
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryElements).Inc()
|
||||
// nolint:staticcheck
|
||||
elementToPatch.FolderID = toFolderID
|
||||
|
Loading…
Reference in New Issue
Block a user