Skip to content

Commit

Permalink
[Image Embeddable] Use client-side authc.getCurrentUser from core.sec…
Browse files Browse the repository at this point in the history
…urity (#186917)

Part of #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
  • Loading branch information
tsullivan authored Jun 26, 2024
1 parent 72090ee commit 15a495a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -27,8 +27,8 @@ export const openImageEditor = async ({
}): Promise<ImageConfig> => {
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<FileImageMetadata>();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -48,7 +46,6 @@ export const setKibanaServices = (
) => {
coreServices = kibanaCore;
filesService = deps.files;
securityService = deps.security;
uiActionsService = deps.uiActions;
screenshotModeService = deps.screenshotMode;

Expand Down
1 change: 0 additions & 1 deletion src/plugins/image_embeddable/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/**/*"]
Expand Down

0 comments on commit 15a495a

Please sign in to comment.