diff --git a/src/plugins/workspace/server/permission_control/client.ts b/src/plugins/workspace/server/permission_control/client.ts index 137016721a60..46232a21cbae 100644 --- a/src/plugins/workspace/server/permission_control/client.ts +++ b/src/plugins/workspace/server/permission_control/client.ts @@ -11,6 +11,7 @@ import { SavedObjectsBulkGetObject, SavedObjectsServiceStart, Logger, + WORKSPACE_TYPE, } from '../../../../core/server'; import { WORKSPACE_SAVED_OBJECTS_CLIENT_WRAPPER_ID } from '../../common/constants'; import { getPrincipalsFromRequest } from '../utils'; @@ -28,6 +29,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/saved_objects/integration_tests/workspace_saved_objects_client_wrapper.test.ts b/src/plugins/workspace/server/saved_objects/integration_tests/workspace_saved_objects_client_wrapper.test.ts index 68717ccf80fc..c883bd33c0a6 100644 --- a/src/plugins/workspace/server/saved_objects/integration_tests/workspace_saved_objects_client_wrapper.test.ts +++ b/src/plugins/workspace/server/saved_objects/integration_tests/workspace_saved_objects_client_wrapper.test.ts @@ -3,15 +3,18 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { ISavedObjectsRepository, SavedObjectsClientContract } from 'src/core/server'; - import { createTestServers, TestOpenSearchUtils, TestOpenSearchDashboardsUtils, TestUtils, } from '../../../../../core/test_helpers/osd_server'; -import { SavedObjectsErrorHelpers } from '../../../../../core/server'; +import { + SavedObjectsErrorHelpers, + WORKSPACE_TYPE, + ISavedObjectsRepository, + SavedObjectsClientContract, +} from '../../../../../core/server'; import { httpServerMock } from '../../../../../../src/core/server/mocks'; import * as utilsExports from '../../utils'; @@ -77,7 +80,9 @@ describe('WorkspaceSavedObjectsClientWrapper', () => { opensearchServer = await servers.startOpenSearch(); osd = await servers.startOpenSearchDashboards(); - internalSavedObjectsRepository = osd.coreStart.savedObjects.createInternalRepository(); + internalSavedObjectsRepository = osd.coreStart.savedObjects.createInternalRepository([ + WORKSPACE_TYPE, + ]); await repositoryKit.create( internalSavedObjectsRepository, @@ -122,9 +127,12 @@ describe('WorkspaceSavedObjectsClientWrapper', () => { return { users: ['foo'] }; }); - permittedSavedObjectedClient = osd.coreStart.savedObjects.getScopedClient(permittedRequest); + permittedSavedObjectedClient = osd.coreStart.savedObjects.getScopedClient(permittedRequest, { + includedHiddenTypes: [WORKSPACE_TYPE], + }); notPermittedSavedObjectedClient = osd.coreStart.savedObjects.getScopedClient( - notPermittedRequest + notPermittedRequest, + { includedHiddenTypes: [WORKSPACE_TYPE] } ); });