diff --git a/x-pack/legacy/plugins/security/server/lib/authorization/check_privileges_dynamically.test.ts b/x-pack/legacy/plugins/security/server/lib/authorization/check_privileges_dynamically.test.ts index b6d91b287dd2ef..188fa4b0061c0f 100644 --- a/x-pack/legacy/plugins/security/server/lib/authorization/check_privileges_dynamically.test.ts +++ b/x-pack/legacy/plugins/security/server/lib/authorization/check_privileges_dynamically.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { SpacesPlugin } from '../../../../spaces/types'; +import { SpacesPlugin } from '../../../../spaces'; import { OptionalPlugin } from '../../../../../server/lib/optional_plugin'; import { checkPrivilegesDynamicallyWithRequestFactory } from './check_privileges_dynamically'; @@ -18,6 +18,10 @@ test(`checkPrivileges.atSpace when spaces is enabled`, async () => { const mockSpaces = { isEnabled: true, getSpaceId: jest.fn().mockReturnValue(spaceId), + spaceIdToNamespace: jest.fn(), + namespaceToSpaceId: jest.fn(), + getBasePath: jest.fn(), + getScopedSpacesClient: jest.fn(), } as OptionalPlugin; const request = Symbol(); const privilegeOrPrivileges = ['foo', 'bar']; diff --git a/x-pack/legacy/plugins/security/server/lib/authorization/check_privileges_dynamically.ts b/x-pack/legacy/plugins/security/server/lib/authorization/check_privileges_dynamically.ts index 5778ccbc76affa..537bc07f8e80c2 100644 --- a/x-pack/legacy/plugins/security/server/lib/authorization/check_privileges_dynamically.ts +++ b/x-pack/legacy/plugins/security/server/lib/authorization/check_privileges_dynamically.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { Legacy } from 'kibana'; import { CheckPrivilegesAtResourceResponse, CheckPrivilegesWithRequest } from './check_privileges'; /* @@ -12,7 +13,7 @@ import { CheckPrivilegesAtResourceResponse, CheckPrivilegesWithRequest } from '. * you may not use this file except in compliance with the Elastic License. */ -import { SpacesPlugin } from '../../../../spaces/types'; +import { SpacesPlugin } from '../../../../spaces'; import { OptionalPlugin } from '../../../../../server/lib/optional_plugin'; export type CheckPrivilegesDynamically = ( @@ -20,14 +21,14 @@ export type CheckPrivilegesDynamically = ( ) => Promise; export type CheckPrivilegesDynamicallyWithRequest = ( - request: Record + request: Legacy.Request ) => CheckPrivilegesDynamically; export function checkPrivilegesDynamicallyWithRequestFactory( checkPrivilegesWithRequest: CheckPrivilegesWithRequest, spaces: OptionalPlugin ): CheckPrivilegesDynamicallyWithRequest { - return function checkPrivilegesDynamicallyWithRequest(request: Record) { + return function checkPrivilegesDynamicallyWithRequest(request: Legacy.Request) { const checkPrivileges = checkPrivilegesWithRequest(request); return async function checkPrivilegesDynamically(privilegeOrPrivileges: string | string[]) { if (spaces.isEnabled) { diff --git a/x-pack/legacy/plugins/security/server/lib/authorization/service.ts b/x-pack/legacy/plugins/security/server/lib/authorization/service.ts index f0274056e25056..8ab90e3a7018c8 100644 --- a/x-pack/legacy/plugins/security/server/lib/authorization/service.ts +++ b/x-pack/legacy/plugins/security/server/lib/authorization/service.ts @@ -7,7 +7,7 @@ import { Server } from 'hapi'; import { getClient } from '../../../../../server/lib/get_client_shield'; -import { SpacesPlugin } from '../../../../spaces/types'; +import { SpacesPlugin } from '../../../../spaces'; import { XPackFeature, XPackMainPlugin } from '../../../../xpack_main/xpack_main'; import { APPLICATION_PREFIX } from '../../../common/constants'; import { OptionalPlugin } from '../../../../../server/lib/optional_plugin'; diff --git a/x-pack/legacy/plugins/spaces/index.ts b/x-pack/legacy/plugins/spaces/index.ts index 9bc5293a3475ed..f583e6d07f9158 100644 --- a/x-pack/legacy/plugins/spaces/index.ts +++ b/x-pack/legacy/plugins/spaces/index.ts @@ -23,6 +23,16 @@ import { } from './server/new_platform/plugin'; import { initSpacesRequestInterceptors } from './server/lib/request_interceptors'; import { SecurityPlugin } from '../security'; +import { SpacesServiceSetup } from './server/new_platform/spaces_service/spaces_service'; + +export interface SpacesPlugin { + getSpaceId: SpacesServiceSetup['getSpaceId']; + spaceIdToNamespace: SpacesServiceSetup['spaceIdToNamespace']; + namespaceToSpaceId: SpacesServiceSetup['namespaceToSpaceId']; + getBasePath: SpacesServiceSetup['getBasePath']; + getScopedSpacesClient: SpacesServiceSetup['scopedClient']; +} + export const spaces = (kibana: Record) => new kibana.Plugin({ id: 'spaces', diff --git a/x-pack/legacy/plugins/spaces/types.d.ts b/x-pack/legacy/plugins/spaces/types.d.ts deleted file mode 100644 index 98a20203c13c12..00000000000000 --- a/x-pack/legacy/plugins/spaces/types.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -import { Request } from 'hapi'; - -export interface SpacesPlugin { - getSpaceId(request: Record): string; -}