RBAC: Handle case when folder id is negative (#53438) (#53439)

(cherry picked from commit 592d31e617)

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2022-08-09 04:26:24 -04:00
committed by GitHub
co-authored by Karl Persson
parent 712b474226
commit 806b7405aa
+5
View File
@@ -130,6 +130,10 @@ func NewDashboardUIDScopeResolver(db Store) (string, ac.ScopeAttributeResolver)
func resolveDashboardScope(ctx context.Context, db Store, orgID int64, dashboard *models.Dashboard) ([]string, error) {
var folderUID string
if dashboard.FolderId < 0 {
return []string{ScopeDashboardsProvider.GetResourceScopeUID(dashboard.Uid)}, nil
}
if dashboard.FolderId == 0 {
folderUID = ac.GeneralFolderUID
} else {
@@ -139,6 +143,7 @@ func resolveDashboardScope(ctx context.Context, db Store, orgID int64, dashboard
}
folderUID = folder.Uid
}
return []string{
ScopeDashboardsProvider.GetResourceScopeUID(dashboard.Uid),
ScopeFoldersProvider.GetResourceScopeUID(folderUID),