From bbb5d3ade4a3b7de47ba7915bc4836e5b845eb69 Mon Sep 17 00:00:00 2001 From: Joe Portner <5295965+jportner@users.noreply.github.com> Date: Tue, 5 Oct 2021 09:30:39 -0400 Subject: [PATCH] Invert dependency between security and share plugins --- .../common/anonymous_access/index.mock.ts | 16 ++++++++ .../share/common/anonymous_access/index.ts | 9 +++++ .../share/common/anonymous_access/types.ts | 39 +++++++++++++++++++ src/plugins/share/common/index.ts | 1 + src/plugins/share/kibana.json | 2 +- .../public/components/share_context_menu.tsx | 4 +- .../public/components/url_panel_content.tsx | 8 ++-- src/plugins/share/public/mocks.ts | 1 + src/plugins/share/public/plugin.test.ts | 27 ++++++++++--- src/plugins/share/public/plugin.ts | 22 +++++++---- .../public/services/share_menu_manager.tsx | 7 ++-- src/plugins/share/tsconfig.json | 1 - x-pack/plugins/security/common/index.ts | 1 - x-pack/plugins/security/common/types.ts | 5 --- x-pack/plugins/security/kibana.json | 2 +- .../anonymous_access_service.ts | 25 ++++++++---- .../public/anonymous_access/index.mock.ts | 15 ------- .../security/public/anonymous_access/index.ts | 2 +- x-pack/plugins/security/public/index.ts | 1 - x-pack/plugins/security/public/mocks.ts | 2 - .../plugins/security/public/plugin.test.tsx | 4 -- x-pack/plugins/security/public/plugin.tsx | 21 ++++++---- .../routes/anonymous_access/get_state.ts | 2 +- x-pack/plugins/security/tsconfig.json | 1 + 24 files changed, 148 insertions(+), 70 deletions(-) create mode 100644 src/plugins/share/common/anonymous_access/index.mock.ts create mode 100644 src/plugins/share/common/anonymous_access/index.ts create mode 100644 src/plugins/share/common/anonymous_access/types.ts delete mode 100644 x-pack/plugins/security/public/anonymous_access/index.mock.ts diff --git a/src/plugins/share/common/anonymous_access/index.mock.ts b/src/plugins/share/common/anonymous_access/index.mock.ts new file mode 100644 index 0000000000000..9b5a8500dff5a --- /dev/null +++ b/src/plugins/share/common/anonymous_access/index.mock.ts @@ -0,0 +1,16 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { AnonymousAccessServiceContract } from './types'; + +export const anonymousAccessMock = { + create: (): jest.Mocked => ({ + getState: jest.fn(), + getCapabilities: jest.fn(), + }), +}; diff --git a/src/plugins/share/common/anonymous_access/index.ts b/src/plugins/share/common/anonymous_access/index.ts new file mode 100644 index 0000000000000..d9746fdd247b5 --- /dev/null +++ b/src/plugins/share/common/anonymous_access/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export type { AnonymousAccessServiceContract, AnonymousAccessState } from './types'; diff --git a/src/plugins/share/common/anonymous_access/types.ts b/src/plugins/share/common/anonymous_access/types.ts new file mode 100644 index 0000000000000..7ab731dfabaaa --- /dev/null +++ b/src/plugins/share/common/anonymous_access/types.ts @@ -0,0 +1,39 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { Capabilities } from 'src/core/public'; + +/** + * The contract that is used to check anonymous access for the purposes of sharing public links. The implementation is intended to be + * provided by the security plugin. + */ +export interface AnonymousAccessServiceContract { + /** + * This function returns the current state of anonymous access. + */ + getState: () => Promise; + /** + * This function returns the capabilities of the anonymous access user. + */ + getCapabilities: () => Promise; +} + +/** + * The state of anonymous access. + */ +export interface AnonymousAccessState { + /** + * Whether anonymous access is enabled or not. + */ + isEnabled: boolean; + /** + * If anonymous access is enabled, this reflects what URL parameters need to be added to a Kibana link to make it publicly accessible. + * Note that if anonymous access is the only authentication method, this will be null. + */ + accessURLParameters: Record | null; +} diff --git a/src/plugins/share/common/index.ts b/src/plugins/share/common/index.ts index 69898f3d72019..992ec2447855f 100644 --- a/src/plugins/share/common/index.ts +++ b/src/plugins/share/common/index.ts @@ -7,3 +7,4 @@ */ export { LocatorDefinition, LocatorPublic, useLocatorUrl, formatSearchParams } from './url_service'; +export type { AnonymousAccessServiceContract, AnonymousAccessState } from './anonymous_access'; diff --git a/src/plugins/share/kibana.json b/src/plugins/share/kibana.json index 989db77854a26..2e34da1da0287 100644 --- a/src/plugins/share/kibana.json +++ b/src/plugins/share/kibana.json @@ -9,5 +9,5 @@ }, "description": "Adds URL Service and sharing capabilities to Kibana", "requiredBundles": ["kibanaUtils"], - "optionalPlugins": ["security"] + "optionalPlugins": [] } diff --git a/src/plugins/share/public/components/share_context_menu.tsx b/src/plugins/share/public/components/share_context_menu.tsx index cad59bf5b843b..8e931c5c579fa 100644 --- a/src/plugins/share/public/components/share_context_menu.tsx +++ b/src/plugins/share/public/components/share_context_menu.tsx @@ -17,7 +17,7 @@ import type { Capabilities } from 'src/core/public'; import { UrlPanelContent } from './url_panel_content'; import { ShareMenuItem, ShareContextMenuPanelItem, UrlParamExtension } from '../types'; -import type { AnonymousAccessServiceStart } from '../../../../../x-pack/plugins/security/public'; +import { AnonymousAccessServiceContract } from '../../common/anonymous_access'; interface Props { allowEmbed: boolean; @@ -31,7 +31,7 @@ interface Props { basePath: string; post: HttpStart['post']; embedUrlParamExtensions?: UrlParamExtension[]; - anonymousAccess?: AnonymousAccessServiceStart; + anonymousAccess?: AnonymousAccessServiceContract; showPublicUrlSwitch?: (anonymousUserCapabilities: Capabilities) => boolean; } diff --git a/src/plugins/share/public/components/url_panel_content.tsx b/src/plugins/share/public/components/url_panel_content.tsx index 9a62e00a3dff2..4fdf6f9b83092 100644 --- a/src/plugins/share/public/components/url_panel_content.tsx +++ b/src/plugins/share/public/components/url_panel_content.tsx @@ -32,8 +32,10 @@ import type { Capabilities } from 'src/core/public'; import { shortenUrl } from '../lib/url_shortener'; import { UrlParamExtension } from '../types'; -import type { AnonymousAccessServiceStart } from '../../../../../x-pack/plugins/security/public'; -import type { AnonymousAccessState } from '../../../../../x-pack/plugins/security/common'; +import { + AnonymousAccessServiceContract, + AnonymousAccessState, +} from '../../common/anonymous_access'; interface Props { allowShortUrl: boolean; @@ -44,7 +46,7 @@ interface Props { basePath: string; post: HttpStart['post']; urlParamExtensions?: UrlParamExtension[]; - anonymousAccess?: AnonymousAccessServiceStart; + anonymousAccess?: AnonymousAccessServiceContract; showPublicUrlSwitch?: (anonymousUserCapabilities: Capabilities) => boolean; } diff --git a/src/plugins/share/public/mocks.ts b/src/plugins/share/public/mocks.ts index 4b8a3b915d13d..73df7257290f0 100644 --- a/src/plugins/share/public/mocks.ts +++ b/src/plugins/share/public/mocks.ts @@ -44,6 +44,7 @@ const createSetupContract = (): Setup => { }, url, navigate: jest.fn(), + setAnonymousAccessServiceProvider: jest.fn(), }; return setupContract; }; diff --git a/src/plugins/share/public/plugin.test.ts b/src/plugins/share/public/plugin.test.ts index b6c89129a6df5..7d5da45f768d5 100644 --- a/src/plugins/share/public/plugin.test.ts +++ b/src/plugins/share/public/plugin.test.ts @@ -10,7 +10,7 @@ import { registryMock, managerMock } from './plugin.test.mocks'; import { SharePlugin } from './plugin'; import { CoreStart } from 'kibana/public'; import { coreMock } from '../../../core/public/mocks'; -import { securityMock } from '../../../../x-pack/plugins/security/public/mocks'; +import { anonymousAccessMock } from '../common/anonymous_access/index.mock'; describe('SharePlugin', () => { beforeEach(() => { @@ -45,17 +45,32 @@ describe('SharePlugin', () => { const coreSetup = coreMock.createSetup(); const service = new SharePlugin(coreMock.createPluginInitializerContext()); await service.setup(coreSetup); - const pluginsStart = { - security: securityMock.createStart(), - }; - const start = await service.start({} as CoreStart, pluginsStart); + const start = await service.start({} as CoreStart); expect(registryMock.start).toHaveBeenCalled(); expect(managerMock.start).toHaveBeenCalledWith( expect.anything(), expect.objectContaining({ getShareMenuItems: expect.any(Function), }), - expect.anything() + undefined + ); + expect(start.toggleShareContextMenu).toBeDefined(); + }); + + test('passes anonymous access service provider to the share menu manager when it is available', async () => { + const coreSetup = coreMock.createSetup(); + const service = new SharePlugin(coreMock.createPluginInitializerContext()); + const setup = await service.setup(coreSetup); + const anonymousAccessServiceProvider = () => anonymousAccessMock.create(); + setup.setAnonymousAccessServiceProvider(anonymousAccessServiceProvider); + const start = await service.start({} as CoreStart); + expect(registryMock.start).toHaveBeenCalled(); + expect(managerMock.start).toHaveBeenCalledWith( + expect.anything(), + expect.objectContaining({ + getShareMenuItems: expect.any(Function), + }), + anonymousAccessServiceProvider ); expect(start.toggleShareContextMenu).toBeDefined(); }); diff --git a/src/plugins/share/public/plugin.ts b/src/plugins/share/public/plugin.ts index a83a2cf1fbe6f..103fbb50bb95f 100644 --- a/src/plugins/share/public/plugin.ts +++ b/src/plugins/share/public/plugin.ts @@ -21,11 +21,7 @@ import { UrlService } from '../common/url_service'; import { RedirectManager } from './url_service'; import type { RedirectOptions } from '../common/url_service/locators/redirect'; import { LegacyShortUrlLocatorDefinition } from '../common/url_service/locators/legacy_short_url_locator'; -import type { SecurityPluginStart } from '../../../../x-pack/plugins/security/public'; - -export interface ShareStartDependencies { - security?: SecurityPluginStart; -} +import { AnonymousAccessServiceContract } from '../common'; /** @public */ export type SharePluginSetup = ShareMenuRegistrySetup & { @@ -46,6 +42,11 @@ export type SharePluginSetup = ShareMenuRegistrySetup & { * the locator, then using the locator to navigate. */ navigate(options: RedirectOptions): void; + + /** + * Sets the provider for the anonymous access service; this is consumed by the Security plugin to avoid a circular dependency. + */ + setAnonymousAccessServiceProvider: (provider: () => AnonymousAccessServiceContract) => void; }; /** @public */ @@ -76,6 +77,7 @@ export class SharePlugin implements Plugin { private redirectManager?: RedirectManager; private url?: UrlService; + private anonymousAccessServiceProvider?: () => AnonymousAccessServiceContract; constructor(private readonly initializerContext: PluginInitializerContext) {} @@ -134,15 +136,21 @@ export class SharePlugin implements Plugin { urlGenerators: this.urlGeneratorsService.setup(core), url: this.url, navigate: (options: RedirectOptions) => this.redirectManager!.navigate(options), + setAnonymousAccessServiceProvider: (provider: () => AnonymousAccessServiceContract) => { + if (this.anonymousAccessServiceProvider) { + throw new Error('Anonymous Access service provider is already set.'); + } + this.anonymousAccessServiceProvider = provider; + }, }; } - public start(core: CoreStart, plugins: ShareStartDependencies): SharePluginStart { + public start(core: CoreStart): SharePluginStart { return { ...this.shareContextMenu.start( core, this.shareMenuRegistry.start(), - plugins.security?.anonymousAccess + this.anonymousAccessServiceProvider ), urlGenerators: this.urlGeneratorsService.start(core), url: this.url!, diff --git a/src/plugins/share/public/services/share_menu_manager.tsx b/src/plugins/share/public/services/share_menu_manager.tsx index 05aa193b777ae..c7251ee4dd414 100644 --- a/src/plugins/share/public/services/share_menu_manager.tsx +++ b/src/plugins/share/public/services/share_menu_manager.tsx @@ -15,7 +15,7 @@ import { CoreStart, HttpStart } from 'kibana/public'; import { ShareContextMenu } from '../components/share_context_menu'; import { ShareMenuItem, ShowShareMenuOptions } from '../types'; import { ShareMenuRegistryStart } from './share_menu_registry'; -import type { AnonymousAccessServiceStart } from '../../../../../x-pack/plugins/security/public'; +import { AnonymousAccessServiceContract } from '../../common/anonymous_access'; export class ShareMenuManager { private isOpen = false; @@ -25,7 +25,7 @@ export class ShareMenuManager { start( core: CoreStart, shareRegistry: ShareMenuRegistryStart, - anonymousAccess?: AnonymousAccessServiceStart + anonymousAccessServiceProvider?: () => AnonymousAccessServiceContract ) { return { /** @@ -35,6 +35,7 @@ export class ShareMenuManager { */ toggleShareContextMenu: (options: ShowShareMenuOptions) => { const menuItems = shareRegistry.getShareMenuItems({ ...options, onClose: this.onClose }); + const anonymousAccess = anonymousAccessServiceProvider?.(); this.toggleShareContextMenu({ ...options, menuItems, @@ -69,7 +70,7 @@ export class ShareMenuManager { menuItems: ShareMenuItem[]; post: HttpStart['post']; basePath: string; - anonymousAccess?: AnonymousAccessServiceStart; + anonymousAccess: AnonymousAccessServiceContract | undefined; }) { if (this.isOpen) { this.onClose(); diff --git a/src/plugins/share/tsconfig.json b/src/plugins/share/tsconfig.json index 979f6d33a441a..1f9c438f03fc4 100644 --- a/src/plugins/share/tsconfig.json +++ b/src/plugins/share/tsconfig.json @@ -10,6 +10,5 @@ "references": [ { "path": "../../core/tsconfig.json" }, { "path": "../kibana_utils/tsconfig.json" }, - { "path": "../../../x-pack/plugins/security/tsconfig.json" } ] } diff --git a/x-pack/plugins/security/common/index.ts b/x-pack/plugins/security/common/index.ts index 77e6fbe90d055..ac5d252c98a8b 100644 --- a/x-pack/plugins/security/common/index.ts +++ b/x-pack/plugins/security/common/index.ts @@ -7,4 +7,3 @@ export type { SecurityLicense } from './licensing'; export type { AuthenticatedUser } from './model'; -export type { AnonymousAccessState } from './types'; diff --git a/x-pack/plugins/security/common/types.ts b/x-pack/plugins/security/common/types.ts index cadc2c5b741b7..e6354841cc9e0 100644 --- a/x-pack/plugins/security/common/types.ts +++ b/x-pack/plugins/security/common/types.ts @@ -19,8 +19,3 @@ export enum LogoutReason { 'LOGGED_OUT' = 'LOGGED_OUT', 'UNAUTHENTICATED' = 'UNAUTHENTICATED', } - -export interface AnonymousAccessState { - isEnabled: boolean; - accessURLParameters: Record | null; -} diff --git a/x-pack/plugins/security/kibana.json b/x-pack/plugins/security/kibana.json index a29c01b0f31cc..538dc86fa52bb 100644 --- a/x-pack/plugins/security/kibana.json +++ b/x-pack/plugins/security/kibana.json @@ -9,7 +9,7 @@ "kibanaVersion": "kibana", "configPath": ["xpack", "security"], "requiredPlugins": ["data", "features", "licensing", "taskManager", "securityOss"], - "optionalPlugins": ["home", "management", "usageCollection", "spaces"], + "optionalPlugins": ["home", "management", "usageCollection", "spaces", "share"], "server": true, "ui": true, "requiredBundles": [ diff --git a/x-pack/plugins/security/public/anonymous_access/anonymous_access_service.ts b/x-pack/plugins/security/public/anonymous_access/anonymous_access_service.ts index 3f06dbdf32074..d67715a2febf0 100644 --- a/x-pack/plugins/security/public/anonymous_access/anonymous_access_service.ts +++ b/x-pack/plugins/security/public/anonymous_access/anonymous_access_service.ts @@ -7,28 +7,37 @@ import type { Capabilities, CoreStart } from 'src/core/public'; -import type { AnonymousAccessState } from '../../common'; +import type { + AnonymousAccessServiceContract, + AnonymousAccessState, +} from '../../../../../src/plugins/share/common'; +import type { SharePluginSetup } from '../../../../../src/plugins/share/public'; const DEFAULT_ANONYMOUS_ACCESS_STATE = Object.freeze({ isEnabled: false, accessURLParameters: null, }); -interface StartDeps { - core: Pick; +interface SetupDeps { + share: SharePluginSetup; } -export interface AnonymousAccessServiceStart { - getState: () => Promise; - getCapabilities: () => Promise; +interface StartDeps { + core: Pick; } /** * Service that allows to retrieve application state. */ export class AnonymousAccessService { - start({ core }: StartDeps): AnonymousAccessServiceStart { - return { + private internalService!: AnonymousAccessServiceContract; + + setup({ share }: SetupDeps) { + share.setAnonymousAccessServiceProvider(() => this.internalService); + } + + start({ core }: StartDeps) { + this.internalService = { getCapabilities: () => core.http.get('/internal/security/anonymous_access/capabilities'), getState: () => diff --git a/x-pack/plugins/security/public/anonymous_access/index.mock.ts b/x-pack/plugins/security/public/anonymous_access/index.mock.ts deleted file mode 100644 index 5960e74b470eb..0000000000000 --- a/x-pack/plugins/security/public/anonymous_access/index.mock.ts +++ /dev/null @@ -1,15 +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 - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { AnonymousAccessServiceStart } from './anonymous_access_service'; - -export const anonymousAccessMock = { - createStart: (): jest.Mocked => ({ - getState: jest.fn(), - getCapabilities: jest.fn(), - }), -}; diff --git a/x-pack/plugins/security/public/anonymous_access/index.ts b/x-pack/plugins/security/public/anonymous_access/index.ts index 2d86cb3a3e3b4..8cee89d1c13d2 100644 --- a/x-pack/plugins/security/public/anonymous_access/index.ts +++ b/x-pack/plugins/security/public/anonymous_access/index.ts @@ -5,4 +5,4 @@ * 2.0. */ -export { AnonymousAccessService, AnonymousAccessServiceStart } from './anonymous_access_service'; +export { AnonymousAccessService } from './anonymous_access_service'; diff --git a/x-pack/plugins/security/public/index.ts b/x-pack/plugins/security/public/index.ts index 229547f317a24..e8d5f739821ed 100644 --- a/x-pack/plugins/security/public/index.ts +++ b/x-pack/plugins/security/public/index.ts @@ -16,7 +16,6 @@ export { SecurityLicense, SecurityLicenseFeatures } from '../common/licensing'; export { UserMenuLink, SecurityNavControlServiceStart } from '../public/nav_control'; export { AuthenticationServiceStart, AuthenticationServiceSetup } from './authentication'; -export { AnonymousAccessServiceStart } from './anonymous_access'; export const plugin: PluginInitializer< SecurityPluginSetup, diff --git a/x-pack/plugins/security/public/mocks.ts b/x-pack/plugins/security/public/mocks.ts index 87f3d02f0caf6..ac478ff0934db 100644 --- a/x-pack/plugins/security/public/mocks.ts +++ b/x-pack/plugins/security/public/mocks.ts @@ -8,7 +8,6 @@ import { licenseMock } from '../common/licensing/index.mock'; import type { MockAuthenticatedUserProps } from '../common/model/authenticated_user.mock'; import { mockAuthenticatedUser } from '../common/model/authenticated_user.mock'; -import { anonymousAccessMock } from './anonymous_access/index.mock'; import { authenticationMock } from './authentication/index.mock'; import { navControlServiceMock } from './nav_control/index.mock'; import { getUiApiMock } from './ui_api/index.mock'; @@ -24,7 +23,6 @@ function createStartMock() { authc: authenticationMock.createStart(), navControlService: navControlServiceMock.createStart(), uiApi: getUiApiMock.createStart(), - anonymousAccess: anonymousAccessMock.createStart(), }; } diff --git a/x-pack/plugins/security/public/plugin.test.tsx b/x-pack/plugins/security/public/plugin.test.tsx index b8f51ab6dd214..258b0ef9ec6f5 100644 --- a/x-pack/plugins/security/public/plugin.test.tsx +++ b/x-pack/plugins/security/public/plugin.test.tsx @@ -114,10 +114,6 @@ describe('Security Plugin', () => { getUserMenuLinks$: expect.any(Function), addUserMenuLinks: expect.any(Function), }, - anonymousAccess: { - getCapabilities: expect.any(Function), - getState: expect.any(Function), - }, }); }); diff --git a/x-pack/plugins/security/public/plugin.tsx b/x-pack/plugins/security/public/plugin.tsx index a4716b35c6084..cddaaad46b5a2 100644 --- a/x-pack/plugins/security/public/plugin.tsx +++ b/x-pack/plugins/security/public/plugin.tsx @@ -16,13 +16,13 @@ import type { } from 'src/plugins/security_oss/public'; import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public'; +import type { SharePluginSetup, SharePluginStart } from '../../../../src/plugins/share/public'; import type { FeaturesPluginStart } from '../../features/public'; import type { LicensingPluginSetup } from '../../licensing/public'; import type { SpacesPluginStart } from '../../spaces/public'; import { SecurityLicenseService } from '../common/licensing'; import type { SecurityLicense } from '../common/licensing'; import { accountManagementApp } from './account_management'; -import type { AnonymousAccessServiceStart } from './anonymous_access'; import { AnonymousAccessService } from './anonymous_access'; import type { AuthenticationServiceSetup, AuthenticationServiceStart } from './authentication'; import { AuthenticationService } from './authentication'; @@ -40,6 +40,7 @@ export interface PluginSetupDependencies { securityOss: SecurityOssPluginSetup; home?: HomePublicPluginSetup; management?: ManagementSetup; + share?: SharePluginSetup; } export interface PluginStartDependencies { @@ -48,6 +49,7 @@ export interface PluginStartDependencies { securityOss: SecurityOssPluginStart; management?: ManagementStart; spaces?: SpacesPluginStart; + share?: SharePluginStart; } export class SecurityPlugin @@ -75,7 +77,7 @@ export class SecurityPlugin public setup( core: CoreSetup, - { home, licensing, management, securityOss }: PluginSetupDependencies + { home, licensing, management, securityOss, share }: PluginSetupDependencies ): SecurityPluginSetup { const { http, notifications } = core; const { anonymousPaths } = http; @@ -138,6 +140,10 @@ export class SecurityPlugin }); } + if (share) { + this.anonymousAccessService.setup({ share }); + } + return { authc: this.authc, license, @@ -146,7 +152,7 @@ export class SecurityPlugin public start( core: CoreStart, - { management, securityOss }: PluginStartDependencies + { management, securityOss, share }: PluginStartDependencies ): SecurityPluginStart { this.sessionTimeout.start(); this.securityCheckupService.start({ securityOssStart: securityOss, docLinks: core.docLinks }); @@ -155,11 +161,14 @@ export class SecurityPlugin this.managementService.start({ capabilities: core.application.capabilities }); } + if (share) { + this.anonymousAccessService.start({ core }); + } + return { uiApi: getUiApi({ core }), navControlService: this.navControlService.start({ core }), authc: this.authc as AuthenticationServiceStart, - anonymousAccess: this.anonymousAccessService.start({ core }), }; } @@ -196,8 +205,4 @@ export interface SecurityPluginStart { * Exposes UI components that will be loaded asynchronously. */ uiApi: UiApi; - /** - * Exposes information about whether anonymous access is available and in what capacity. - */ - anonymousAccess: AnonymousAccessServiceStart; } diff --git a/x-pack/plugins/security/server/routes/anonymous_access/get_state.ts b/x-pack/plugins/security/server/routes/anonymous_access/get_state.ts index b077207548287..f817ade1a10fd 100644 --- a/x-pack/plugins/security/server/routes/anonymous_access/get_state.ts +++ b/x-pack/plugins/security/server/routes/anonymous_access/get_state.ts @@ -6,7 +6,7 @@ */ import type { RouteDefinitionParams } from '..'; -import type { AnonymousAccessState } from '../../../common'; +import type { AnonymousAccessState } from '../../../../../../src/plugins/share/common'; /** * Defines route that returns the state of anonymous access -- whether anonymous access is enabled, and what additional parameters should be diff --git a/x-pack/plugins/security/tsconfig.json b/x-pack/plugins/security/tsconfig.json index ea03b9dbb6471..44776c01cd566 100644 --- a/x-pack/plugins/security/tsconfig.json +++ b/x-pack/plugins/security/tsconfig.json @@ -18,6 +18,7 @@ { "path": "../../../src/plugins/kibana_react/tsconfig.json" }, { "path": "../../../src/plugins/management/tsconfig.json" }, { "path": "../../../src/plugins/security_oss/tsconfig.json" }, + { "path": "../../../src/plugins/share/tsconfig.json" }, { "path": "../../../src/plugins/usage_collection/tsconfig.json" } ] }