mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
FIX: Remove RBAC datasource permissions upon datasource deletion (#56530)
* FIX: Remove RBAC datasource permissions upon datasource deletion * Use scope provider instead * Fix test
This commit is contained in:
parent
0eb3afbd14
commit
7595ed0668
@ -144,7 +144,7 @@ func (ss *SqlStore) DeleteDataSource(ctx context.Context, cmd *datasources.Delet
|
|||||||
|
|
||||||
// Remove associated AccessControl permissions
|
// Remove associated AccessControl permissions
|
||||||
if _, errDeletingPerms := sess.Exec("DELETE FROM permission WHERE scope=?",
|
if _, errDeletingPerms := sess.Exec("DELETE FROM permission WHERE scope=?",
|
||||||
ac.Scope("datasources", "id", fmt.Sprint(dsQuery.Result.Id))); errDeletingPerms != nil {
|
ac.Scope(datasources.ScopeProvider.GetResourceScope(dsQuery.Result.Uid))); errDeletingPerms != nil {
|
||||||
return errDeletingPerms
|
return errDeletingPerms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package service
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -319,7 +318,7 @@ func TestIntegrationDataAccess(t *testing.T) {
|
|||||||
_, err := sess.Table("permission").Insert(ac.Permission{
|
_, err := sess.Table("permission").Insert(ac.Permission{
|
||||||
RoleID: 1,
|
RoleID: 1,
|
||||||
Action: "datasources:read",
|
Action: "datasources:read",
|
||||||
Scope: ac.Scope("datasources", "id", fmt.Sprintf("%d", ds.Id)),
|
Scope: datasources.ScopeProvider.GetResourceScope(ds.Uid),
|
||||||
Updated: time.Now(),
|
Updated: time.Now(),
|
||||||
Created: time.Now(),
|
Created: time.Now(),
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user