From 409468179343c42d0278b8bd27b6d978f536e124 Mon Sep 17 00:00:00 2001 From: SuZhou-Joe Date: Mon, 26 Feb 2024 14:33:04 +0800 Subject: [PATCH] feat: add workspace into includeHiddenTypes of client wrapper and permission control client Signed-off-by: SuZhou-Joe --- src/plugins/workspace/server/permission_control/client.ts | 8 +++++++- src/plugins/workspace/server/plugin.ts | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/plugins/workspace/server/permission_control/client.ts b/src/plugins/workspace/server/permission_control/client.ts index 7ba4a4f454be..b141ec2e7313 100644 --- a/src/plugins/workspace/server/permission_control/client.ts +++ b/src/plugins/workspace/server/permission_control/client.ts @@ -3,7 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ import { i18n } from '@osd/i18n'; -import { OpenSearchDashboardsRequest, Principals, SavedObject } from '../../../../core/server'; +import { + OpenSearchDashboardsRequest, + Principals, + SavedObject, + WORKSPACE_TYPE, +} from '../../../../core/server'; import { ACL, TransformedPermission, @@ -27,6 +32,7 @@ export class SavedObjectsPermissionControl { private getScopedClient(request: OpenSearchDashboardsRequest) { return this._getScopedClient?.(request, { excludedWrappers: [WORKSPACE_SAVED_OBJECTS_CLIENT_WRAPPER_ID], + includedHiddenTypes: [WORKSPACE_TYPE], }); } diff --git a/src/plugins/workspace/server/plugin.ts b/src/plugins/workspace/server/plugin.ts index edf785b4a322..6ae16c3bc545 100644 --- a/src/plugins/workspace/server/plugin.ts +++ b/src/plugins/workspace/server/plugin.ts @@ -11,6 +11,7 @@ import { Plugin, Logger, SavedObjectsClient, + WORKSPACE_TYPE, } from '../../../core/server'; import { IWorkspaceClientImpl } from './types'; import { WorkspaceClientWithSavedObject } from './workspace_client'; @@ -92,7 +93,11 @@ export class WorkspacePlugin implements Plugin<{}, {}> { core.savedObjects.setClientFactoryProvider( (repositoryFactory) => ({ includedHiddenTypes }: { includedHiddenTypes?: string[] }) => - new SavedObjectsClient(repositoryFactory.createInternalRepository(includedHiddenTypes)) + new SavedObjectsClient( + repositoryFactory.createInternalRepository([ + ...new Set([WORKSPACE_TYPE, ...(includedHiddenTypes || [])]), + ]) + ) ); core.capabilities.registerProvider(() => ({