RBAC: Add scope resolvers for dashboards (#50110)
* Inject access control into dashboard service * Add function to parse id scopes * Add dashboard as return value * Update mock * Return only err to keep service interface * Add scope resolvers for dashboard id scopes * Add function to parse uid scopes * Add dashboard uid scope resolver * Register scope resolvers for dashboards Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
This commit is contained in:
co-authored by
Gabriel MABILLE
parent
9f6afb3475
commit
c4a75f9eb3
@@ -113,7 +113,7 @@ func ProvideDashboardPermissions(
|
||||
) (*DashboardPermissionsService, error) {
|
||||
getDashboard := func(ctx context.Context, orgID int64, resourceID string) (*models.Dashboard, error) {
|
||||
query := &models.GetDashboardQuery{Uid: resourceID, OrgId: orgID}
|
||||
if err := dashboardStore.GetDashboard(ctx, query); err != nil {
|
||||
if _, err := dashboardStore.GetDashboard(ctx, query); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return query.Result, nil
|
||||
@@ -142,7 +142,7 @@ func ProvideDashboardPermissions(
|
||||
}
|
||||
if dashboard.FolderId > 0 {
|
||||
query := &models.GetDashboardQuery{Id: dashboard.FolderId, OrgId: orgID}
|
||||
if err := dashboardStore.GetDashboard(ctx, query); err != nil {
|
||||
if _, err := dashboardStore.GetDashboard(ctx, query); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return []string{dashboards.ScopeFoldersProvider.GetResourceScopeUID(query.Result.Uid)}, nil
|
||||
@@ -196,7 +196,7 @@ func ProvideFolderPermissions(
|
||||
ResourceAttribute: "uid",
|
||||
ResourceValidator: func(ctx context.Context, orgID int64, resourceID string) error {
|
||||
query := &models.GetDashboardQuery{Uid: resourceID, OrgId: orgID}
|
||||
if err := dashboardStore.GetDashboard(ctx, query); err != nil {
|
||||
if _, err := dashboardStore.GetDashboard(ctx, query); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user