Skip to content

Commit

Permalink
[Maps] Use client-side authc.getCurrentUser from core.security (#186915)
Browse files Browse the repository at this point in the history
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 Maps plugin uses the
`authc.getCurrentUser` in the `es_search_source` utility.

### 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 25, 2024
1 parent d5b0ddd commit e7c867f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ import { Adapters } from '@kbn/inspector-plugin/common/adapters';
import { SortDirection, SortDirectionNumeric } from '@kbn/data-plugin/common';
import { getTileUrlParams } from '@kbn/maps-vector-tile-utils';
import { AbstractESSource } from '../es_source';
import {
getHttp,
getSearchService,
getSecurityService,
getTimeFilter,
} from '../../../kibana_services';
import { getCore, getHttp, getSearchService, getTimeFilter } from '../../../kibana_services';
import {
addFieldToDSL,
getField,
Expand Down Expand Up @@ -532,7 +527,7 @@ export class ESSearchSource extends AbstractESSource implements IMvtVectorSource
if (!(await this._isDrawingIndex())) {
return {};
}
const user = await getSecurityService()?.authc.getCurrentUser();
const user = await getCore().security.authc.getCurrentUser();
const timestamp = new Date().toISOString();
return {
created: {
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/maps/public/kibana_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export const getUrlForApp = () => coreStart.application.getUrlForApp;
export const getNavigateToUrl = () => coreStart.application.navigateToUrl;
export const getSavedObjectsTagging = () => pluginsStart.savedObjectsTagging;
export const getPresentationUtilContext = () => pluginsStart.presentationUtil.ContextProvider;
export const getSecurityService = () => pluginsStart.security;
export const getSpacesApi = () => pluginsStart.spaces;
export const getTheme = () => coreStart.theme;
export const getApplication = () => coreStart.application;
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import type { FileUploadPluginStart } from '@kbn/file-upload-plugin/public';
import type { PresentationUtilPluginStart } from '@kbn/presentation-util-plugin/public';
import type { SavedObjectTaggingPluginStart } from '@kbn/saved-objects-tagging-plugin/public';
import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
import type { SecurityPluginStart } from '@kbn/security-plugin/public';
import type { SpacesPluginStart } from '@kbn/spaces-plugin/public';
import type { CloudSetup } from '@kbn/cloud-plugin/public';
import type { LensPublicSetup } from '@kbn/lens-plugin/public';
Expand Down Expand Up @@ -123,7 +122,6 @@ export interface MapsPluginStartDependencies {
visualizations: VisualizationsStart;
savedObjectsTagging?: SavedObjectTaggingPluginStart;
presentationUtil: PresentationUtilPluginStart;
security?: SecurityPluginStart;
spaces?: SpacesPluginStart;
mapsEms: MapsEmsPluginPublicStart;
contentManagement: ContentManagementPublicStart;
Expand Down

0 comments on commit e7c867f

Please sign in to comment.