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

This commit is contained in:
Karl Persson 2022-08-09 10:14:08 +02:00 committed by GitHub
parent 59ce564d49
commit 592d31e617
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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),