diff --git a/x-pack/plugins/security/public/authentication/authentication_service.ts b/x-pack/plugins/security/public/authentication/authentication_service.ts index 4f0f69ac68886..202fc1b98452c 100644 --- a/x-pack/plugins/security/public/authentication/authentication_service.ts +++ b/x-pack/plugins/security/public/authentication/authentication_service.ts @@ -42,6 +42,11 @@ export interface AuthenticationServiceSetup { areAPIKeysEnabled: () => Promise; } +/** + * Start has the same contract as Setup for now. + */ +export type AuthenticationServiceStart = AuthenticationServiceSetup; + export class AuthenticationService { public setup({ application, diff --git a/x-pack/plugins/security/public/authentication/index.mock.ts b/x-pack/plugins/security/public/authentication/index.mock.ts index 47c9dad012eae..092126e6cfeed 100644 --- a/x-pack/plugins/security/public/authentication/index.mock.ts +++ b/x-pack/plugins/security/public/authentication/index.mock.ts @@ -5,11 +5,18 @@ * 2.0. */ -import type { AuthenticationServiceSetup } from './authentication_service'; +import type { + AuthenticationServiceSetup, + AuthenticationServiceStart, +} from './authentication_service'; export const authenticationMock = { createSetup: (): jest.Mocked => ({ getCurrentUser: jest.fn(), areAPIKeysEnabled: jest.fn(), }), + createStart: (): jest.Mocked => ({ + getCurrentUser: jest.fn(), + areAPIKeysEnabled: jest.fn(), + }), }; diff --git a/x-pack/plugins/security/public/authentication/index.ts b/x-pack/plugins/security/public/authentication/index.ts index 74b4740d31ef0..50d6b0c74376e 100644 --- a/x-pack/plugins/security/public/authentication/index.ts +++ b/x-pack/plugins/security/public/authentication/index.ts @@ -5,4 +5,8 @@ * 2.0. */ -export { AuthenticationService, AuthenticationServiceSetup } from './authentication_service'; +export { + AuthenticationService, + AuthenticationServiceSetup, + AuthenticationServiceStart, +} from './authentication_service'; diff --git a/x-pack/plugins/security/public/mocks.ts b/x-pack/plugins/security/public/mocks.ts index cac556d04031e..829c3ced9dddb 100644 --- a/x-pack/plugins/security/public/mocks.ts +++ b/x-pack/plugins/security/public/mocks.ts @@ -21,6 +21,7 @@ function createSetupMock() { } function createStartMock() { return { + authc: authenticationMock.createStart(), navControlService: navControlServiceMock.createStart(), }; } diff --git a/x-pack/plugins/security/public/plugin.test.tsx b/x-pack/plugins/security/public/plugin.test.tsx index fa9d11422e884..d3794ddbeb1a6 100644 --- a/x-pack/plugins/security/public/plugin.test.tsx +++ b/x-pack/plugins/security/public/plugin.test.tsx @@ -103,6 +103,10 @@ describe('Security Plugin', () => { features: {} as FeaturesPluginStart, }) ).toEqual({ + authc: { + getCurrentUser: expect.any(Function), + areAPIKeysEnabled: expect.any(Function), + }, navControlService: { getUserMenuLinks$: expect.any(Function), addUserMenuLinks: expect.any(Function), diff --git a/x-pack/plugins/security/public/plugin.tsx b/x-pack/plugins/security/public/plugin.tsx index 5d86f15174633..c805d9f1caf79 100644 --- a/x-pack/plugins/security/public/plugin.tsx +++ b/x-pack/plugins/security/public/plugin.tsx @@ -21,7 +21,7 @@ import type { LicensingPluginSetup } from '../../licensing/public'; import type { SpacesPluginStart } from '../../spaces/public'; import { SecurityLicenseService } from '../common/licensing'; import { accountManagementApp } from './account_management'; -import type { AuthenticationServiceSetup } from './authentication'; +import type { AuthenticationServiceSetup, AuthenticationServiceStart } from './authentication'; import { AuthenticationService } from './authentication'; import type { ConfigType } from './config'; import { ManagementService } from './management'; @@ -153,7 +153,10 @@ export class SecurityPlugin this.managementService.start({ capabilities: core.application.capabilities }); } - return { navControlService: this.navControlService.start({ core }) }; + return { + navControlService: this.navControlService.start({ core }), + authc: this.authc as AuthenticationServiceStart, + }; } public stop() {