mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Folders: GetFolders to return empty respons if user does not have any permissions (#81304)
add check for list of permissions
This commit is contained in:
parent
09fcb3c6cc
commit
a081abdd25
@ -131,6 +131,9 @@ func (s *Service) GetFolders(ctx context.Context, q folder.GetFoldersQuery) ([]*
|
||||
permissions := q.SignedInUser.GetPermissions()
|
||||
folderPermissions := permissions[dashboards.ActionFoldersRead]
|
||||
qry.ancestorUIDs = make([]string, 0, len(folderPermissions))
|
||||
if len(folderPermissions) == 0 && !q.SignedInUser.GetIsGrafanaAdmin() {
|
||||
return nil, nil
|
||||
}
|
||||
for _, p := range folderPermissions {
|
||||
if p == dashboards.ScopeFoldersAll {
|
||||
// no need to query for folders with permissions
|
||||
|
@ -1309,6 +1309,7 @@ func TestIntegrationNestedFolderSharedWithMe(t *testing.T) {
|
||||
orgID: {
|
||||
dashboards.ActionFoldersCreate: {},
|
||||
dashboards.ActionFoldersWrite: {dashboards.ScopeFoldersAll},
|
||||
dashboards.ActionFoldersRead: {dashboards.ScopeFoldersAll},
|
||||
},
|
||||
}}
|
||||
|
||||
@ -1587,6 +1588,16 @@ func TestIntegrationNestedFolderSharedWithMe(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Should not get any folders if user has no permissions",
|
||||
cmd: folder.GetFoldersQuery{
|
||||
OrgID: orgID,
|
||||
SignedInUser: &user.SignedInUser{UserID: 999, OrgID: orgID, Permissions: map[int64]map[string][]string{
|
||||
orgID: {},
|
||||
}},
|
||||
},
|
||||
expected: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
Loading…
Reference in New Issue
Block a user