From 15a495a1b25312e8fac19740780bde16f4a5f0f2 Mon Sep 17 00:00:00 2001 From: Tim Sullivan Date: Wed, 26 Jun 2024 10:03:25 -0700 Subject: [PATCH] [Image Embeddable] Use client-side authc.getCurrentUser from core.security (#186917) Part of https://github.com/elastic/kibana/issues/186574 Background: This PR serves as an example of a plugin migrating away from depending on the Security plugin, which is a high priority effort for the last release before 9.0. The Image Embeddable plugin uses the `authc.getCurrentUser` method as a means to allow the user to delete image files that are attributed to them. ### Checklist Delete any items that are not applicable to this PR. - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --- .../public/components/image_editor/open_image_editor.tsx | 6 +++--- .../image_embeddable/public/services/kibana_services.ts | 3 --- src/plugins/image_embeddable/tsconfig.json | 1 - 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/plugins/image_embeddable/public/components/image_editor/open_image_editor.tsx b/src/plugins/image_embeddable/public/components/image_editor/open_image_editor.tsx index dd2932164c014..c737640a4f1b9 100644 --- a/src/plugins/image_embeddable/public/components/image_editor/open_image_editor.tsx +++ b/src/plugins/image_embeddable/public/components/image_editor/open_image_editor.tsx @@ -14,7 +14,7 @@ import { FilesContext } from '@kbn/shared-ux-file-context'; import { ImageConfig } from '../../image_embeddable/types'; import { FileImageMetadata, imageEmbeddableFileKind } from '../../imports'; -import { coreServices, filesService, securityService } from '../../services/kibana_services'; +import { coreServices, filesService } from '../../services/kibana_services'; import { createValidateUrl } from '../../utils/validate_url'; import { ImageViewerContext } from '../image_viewer/image_viewer_context'; @@ -27,8 +27,8 @@ export const openImageEditor = async ({ }): Promise => { const { ImageEditorFlyout } = await import('./image_editor_flyout'); - const { overlays, theme, i18n, http } = coreServices; - const user = securityService ? await securityService.authc.getCurrentUser() : undefined; + const { overlays, theme, i18n, http, security } = coreServices; + const user = await security.authc.getCurrentUser(); const filesClient = filesService.filesClientFactory.asUnscoped(); /** diff --git a/src/plugins/image_embeddable/public/services/kibana_services.ts b/src/plugins/image_embeddable/public/services/kibana_services.ts index a04328bb6e041..84711a3c2350c 100644 --- a/src/plugins/image_embeddable/public/services/kibana_services.ts +++ b/src/plugins/image_embeddable/public/services/kibana_services.ts @@ -11,7 +11,6 @@ import { BehaviorSubject } from 'rxjs'; import { CoreStart } from '@kbn/core/public'; import { FilesStart } from '@kbn/files-plugin/public'; import { ScreenshotModePluginStart } from '@kbn/screenshot-mode-plugin/public'; -import { SecurityPluginStart } from '@kbn/security-plugin-types-public'; import { UiActionsStart } from '@kbn/ui-actions-plugin/public'; import { ImageEmbeddableStartDependencies } from '../plugin'; @@ -20,7 +19,6 @@ export let coreServices: CoreStart; export let filesService: FilesStart; export let uiActionsService: UiActionsStart; export let screenshotModeService: ScreenshotModePluginStart | undefined; -export let securityService: SecurityPluginStart | undefined; export let trackUiMetric: ( type: string, @@ -48,7 +46,6 @@ export const setKibanaServices = ( ) => { coreServices = kibanaCore; filesService = deps.files; - securityService = deps.security; uiActionsService = deps.uiActions; screenshotModeService = deps.screenshotMode; diff --git a/src/plugins/image_embeddable/tsconfig.json b/src/plugins/image_embeddable/tsconfig.json index 7e54325cb7762..d9863cf7fd6ac 100644 --- a/src/plugins/image_embeddable/tsconfig.json +++ b/src/plugins/image_embeddable/tsconfig.json @@ -23,7 +23,6 @@ "@kbn/presentation-containers", "@kbn/presentation-publishing", "@kbn/react-kibana-mount", - "@kbn/security-plugin-types-public", "@kbn/embeddable-enhanced-plugin" ], "exclude": ["target/**/*"]