From d1bc2641a6eff20e8e4e5b0bb09992d4a0a8bfc8 Mon Sep 17 00:00:00 2001 From: Giorgos Bamparopoulos Date: Tue, 30 Nov 2021 10:02:31 +0000 Subject: [PATCH] [APM] Add Agent Keys in APM settings - Agent key table (#119543) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add agent keys table * Add support for invalidating keys Co-authored-by: Søren Louv-Jansen Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../Settings/agent_keys/agent_keys_table.tsx | 168 ++++++++++++++++ .../agent_keys/confirm_delete_modal.tsx | 84 ++++++++ .../app/Settings/agent_keys/index.tsx | 186 ++++++++++++++++++ .../prompts/api_keys_not_enabled.tsx | 56 ++++++ .../agent_keys/prompts/permission_denied.tsx | 38 ++++ .../components/routing/settings/index.tsx | 9 + .../routing/templates/settings_template.tsx | 14 +- .../routes/agent_keys/get_agent_keys.ts | 45 +++++ .../agent_keys/get_agent_keys_privileges.ts | 55 ++++++ .../routes/agent_keys/invalidate_agent_key.ts | 29 +++ .../apm/server/routes/agent_keys/route.ts | 85 ++++++++ .../get_global_apm_server_route_repository.ts | 5 +- 12 files changed, 772 insertions(+), 2 deletions(-) create mode 100644 x-pack/plugins/apm/public/components/app/Settings/agent_keys/agent_keys_table.tsx create mode 100644 x-pack/plugins/apm/public/components/app/Settings/agent_keys/confirm_delete_modal.tsx create mode 100644 x-pack/plugins/apm/public/components/app/Settings/agent_keys/index.tsx create mode 100644 x-pack/plugins/apm/public/components/app/Settings/agent_keys/prompts/api_keys_not_enabled.tsx create mode 100644 x-pack/plugins/apm/public/components/app/Settings/agent_keys/prompts/permission_denied.tsx create mode 100644 x-pack/plugins/apm/server/routes/agent_keys/get_agent_keys.ts create mode 100644 x-pack/plugins/apm/server/routes/agent_keys/get_agent_keys_privileges.ts create mode 100644 x-pack/plugins/apm/server/routes/agent_keys/invalidate_agent_key.ts create mode 100644 x-pack/plugins/apm/server/routes/agent_keys/route.ts diff --git a/x-pack/plugins/apm/public/components/app/Settings/agent_keys/agent_keys_table.tsx b/x-pack/plugins/apm/public/components/app/Settings/agent_keys/agent_keys_table.tsx new file mode 100644 index 0000000000000..4a05f38d8e505 --- /dev/null +++ b/x-pack/plugins/apm/public/components/app/Settings/agent_keys/agent_keys_table.tsx @@ -0,0 +1,168 @@ +/* + * 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 React, { useState } from 'react'; +import { i18n } from '@kbn/i18n'; +import { + EuiInMemoryTable, + EuiBasicTableColumn, + EuiInMemoryTableProps, +} from '@elastic/eui'; +import { TimestampTooltip } from '../../../shared/TimestampTooltip'; +import { ApiKey } from '../../../../../../security/common/model'; +import { ConfirmDeleteModal } from './confirm_delete_modal'; + +interface Props { + agentKeys: ApiKey[]; + refetchAgentKeys: () => void; +} + +export function AgentKeysTable({ agentKeys, refetchAgentKeys }: Props) { + const [agentKeyToBeDeleted, setAgentKeyToBeDeleted] = useState(); + + const columns: Array> = [ + { + field: 'name', + name: i18n.translate( + 'xpack.apm.settings.agentKeys.table.nameColumnName', + { + defaultMessage: 'Name', + } + ), + sortable: true, + }, + { + field: 'username', + name: i18n.translate( + 'xpack.apm.settings.agentKeys.table.userNameColumnName', + { + defaultMessage: 'User', + } + ), + sortable: true, + }, + { + field: 'realm', + name: i18n.translate( + 'xpack.apm.settings.agentKeys.table.realmColumnName', + { + defaultMessage: 'Realm', + } + ), + sortable: true, + }, + { + field: 'creation', + name: i18n.translate( + 'xpack.apm.settings.agentKeys.table.creationColumnName', + { + defaultMessage: 'Created', + } + ), + dataType: 'date', + sortable: true, + mobileOptions: { + show: false, + }, + render: (date: number) => , + }, + { + actions: [ + { + name: i18n.translate( + 'xpack.apm.settings.agentKeys.table.deleteActionTitle', + { + defaultMessage: 'Delete', + } + ), + description: i18n.translate( + 'xpack.apm.settings.agentKeys.table.deleteActionDescription', + { + defaultMessage: 'Delete this agent key', + } + ), + icon: 'trash', + color: 'danger', + type: 'icon', + onClick: (agentKey: ApiKey) => setAgentKeyToBeDeleted(agentKey), + }, + ], + }, + ]; + + const search: EuiInMemoryTableProps['search'] = { + box: { + incremental: true, + }, + filters: [ + { + type: 'field_value_selection', + field: 'username', + name: i18n.translate( + 'xpack.apm.settings.agentKeys.table.userFilterLabel', + { + defaultMessage: 'User', + } + ), + multiSelect: 'or', + operator: 'exact', + options: Object.keys( + agentKeys.reduce((acc: Record, { username }) => { + acc[username] = true; + return acc; + }, {}) + ).map((value) => ({ value })), + }, + { + type: 'field_value_selection', + field: 'realm', + name: i18n.translate( + 'xpack.apm.settings.agentKeys.table.realmFilterLabel', + { + defaultMessage: 'Realm', + } + ), + multiSelect: 'or', + operator: 'exact', + options: Object.keys( + agentKeys.reduce((acc: Record, { realm }) => { + acc[realm] = true; + return acc; + }, {}) + ).map((value) => ({ value })), + }, + ], + }; + + return ( + + + {agentKeyToBeDeleted && ( + setAgentKeyToBeDeleted(undefined)} + agentKey={agentKeyToBeDeleted} + onConfirm={() => { + setAgentKeyToBeDeleted(undefined); + refetchAgentKeys(); + }} + /> + )} + + ); +} diff --git a/x-pack/plugins/apm/public/components/app/Settings/agent_keys/confirm_delete_modal.tsx b/x-pack/plugins/apm/public/components/app/Settings/agent_keys/confirm_delete_modal.tsx new file mode 100644 index 0000000000000..6125a238f11aa --- /dev/null +++ b/x-pack/plugins/apm/public/components/app/Settings/agent_keys/confirm_delete_modal.tsx @@ -0,0 +1,84 @@ +/* + * 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 React, { useState } from 'react'; +import { i18n } from '@kbn/i18n'; +import { EuiConfirmModal } from '@elastic/eui'; +import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context'; +import { callApmApi } from '../../../../services/rest/createCallApmApi'; +import { ApiKey } from '../../../../../../security/common/model'; + +interface Props { + agentKey: ApiKey; + onCancel: () => void; + onConfirm: () => void; +} + +export function ConfirmDeleteModal({ agentKey, onCancel, onConfirm }: Props) { + const [isDeleting, setIsDeleting] = useState(false); + const { toasts } = useApmPluginContext().core.notifications; + const { id, name } = agentKey; + + const deleteAgentKey = async () => { + try { + await callApmApi({ + endpoint: 'POST /internal/apm/api_key/invalidate', + signal: null, + params: { + body: { id }, + }, + }); + toasts.addSuccess( + i18n.translate('xpack.apm.settings.agentKeys.invalidate.succeeded', { + defaultMessage: 'Deleted agent key "{name}"', + values: { name }, + }) + ); + } catch (error) { + toasts.addDanger( + i18n.translate('xpack.apm.settings.agentKeys.invalidate.failed', { + defaultMessage: 'Error deleting agent key "{name}"', + values: { name }, + }) + ); + } + }; + + return ( + { + setIsDeleting(true); + await deleteAgentKey(); + setIsDeleting(false); + onConfirm(); + }} + cancelButtonText={i18n.translate( + 'xpack.apm.settings.agentKeys.deleteConfirmModal.cancel', + { + defaultMessage: 'Cancel', + } + )} + confirmButtonText={i18n.translate( + 'xpack.apm.settings.agentKeys.deleteConfirmModal.delete', + { + defaultMessage: 'Delete', + } + )} + confirmButtonDisabled={isDeleting} + buttonColor="danger" + defaultFocusedButton="confirm" + /> + ); +} diff --git a/x-pack/plugins/apm/public/components/app/Settings/agent_keys/index.tsx b/x-pack/plugins/apm/public/components/app/Settings/agent_keys/index.tsx new file mode 100644 index 0000000000000..23acc2e98dd73 --- /dev/null +++ b/x-pack/plugins/apm/public/components/app/Settings/agent_keys/index.tsx @@ -0,0 +1,186 @@ +/* + * 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 React, { Fragment } from 'react'; +import { isEmpty } from 'lodash'; +import { i18n } from '@kbn/i18n'; +import { + EuiText, + EuiSpacer, + EuiTitle, + EuiFlexGroup, + EuiFlexItem, + EuiEmptyPrompt, + EuiButton, + EuiLoadingSpinner, +} from '@elastic/eui'; +import { useFetcher, FETCH_STATUS } from '../../../../hooks/use_fetcher'; +import { PermissionDenied } from './prompts/permission_denied'; +import { ApiKeysNotEnabled } from './prompts/api_keys_not_enabled'; +import { AgentKeysTable } from './agent_keys_table'; + +const INITIAL_DATA = { + areApiKeysEnabled: false, + canManage: false, +}; + +export function AgentKeys() { + return ( + + + {i18n.translate('xpack.apm.settings.agentKeys.descriptionText', { + defaultMessage: + 'View and delete agent keys. An agent key sends requests on behalf of a user.', + })} + + + + + +

+ {i18n.translate('xpack.apm.settings.agentKeys.title', { + defaultMessage: 'Agent keys', + })} +

+
+
+
+ + +
+ ); +} + +function AgentKeysContent() { + const { + data: { areApiKeysEnabled, canManage } = INITIAL_DATA, + status: privilegesStatus, + } = useFetcher( + (callApmApi) => { + return callApmApi({ + endpoint: 'GET /internal/apm/agent_keys/privileges', + }); + }, + [], + { showToastOnError: false } + ); + + const { + data, + status, + refetch: refetchAgentKeys, + } = useFetcher( + (callApmApi) => { + if (areApiKeysEnabled && canManage) { + return callApmApi({ + endpoint: 'GET /internal/apm/agent_keys', + }); + } + }, + [areApiKeysEnabled, canManage], + { showToastOnError: false } + ); + + const agentKeys = data?.agentKeys; + const isLoading = + privilegesStatus === FETCH_STATUS.LOADING || + status === FETCH_STATUS.LOADING; + + const requestFailed = + privilegesStatus === FETCH_STATUS.FAILURE || + status === FETCH_STATUS.FAILURE; + + if (!agentKeys) { + if (isLoading) { + return ( + } + titleSize="xs" + title={ +

+ {i18n.translate( + 'xpack.apm.settings.agentKeys.agentKeysLoadingPromptTitle', + { + defaultMessage: 'Loading Agent keys...', + } + )} +

+ } + /> + ); + } + + if (requestFailed) { + return ( + + {i18n.translate( + 'xpack.apm.settings.agentKeys.agentKeysErrorPromptTitle', + { + defaultMessage: 'Could not load agent keys.', + } + )} + + } + /> + ); + } + + if (!canManage) { + return ; + } + + if (!areApiKeysEnabled) { + return ; + } + } + + if (agentKeys && isEmpty(agentKeys)) { + return ( + + {i18n.translate('xpack.apm.settings.agentKeys.emptyPromptTitle', { + defaultMessage: 'Create your first agent key', + })} + + } + body={ +

+ {i18n.translate('xpack.apm.settings.agentKeys.emptyPromptBody', { + defaultMessage: + 'Create agent keys to authorize requests to the APM Server.', + })} +

+ } + actions={ + + {i18n.translate( + 'xpack.apm.settings.agentKeys.createAgentKeyButton', + { + defaultMessage: 'Create agent key', + } + )} + + } + /> + ); + } + + if (agentKeys && !isEmpty(agentKeys)) { + return ( + + ); + } + + return null; +} diff --git a/x-pack/plugins/apm/public/components/app/Settings/agent_keys/prompts/api_keys_not_enabled.tsx b/x-pack/plugins/apm/public/components/app/Settings/agent_keys/prompts/api_keys_not_enabled.tsx new file mode 100644 index 0000000000000..5d667b9f3e1a4 --- /dev/null +++ b/x-pack/plugins/apm/public/components/app/Settings/agent_keys/prompts/api_keys_not_enabled.tsx @@ -0,0 +1,56 @@ +/* + * 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 { EuiEmptyPrompt, EuiLink } from '@elastic/eui'; +import React from 'react'; +import { FormattedMessage } from '@kbn/i18n-react'; +import { i18n } from '@kbn/i18n'; +import { useKibana } from '../../../../../../../../../src/plugins/kibana_react/public'; + +export function ApiKeysNotEnabled() { + const { + services: { docLinks }, + } = useKibana(); + + return ( + + {i18n.translate( + 'xpack.apm.settings.agentKeys.apiKeysDisabledErrorTitle', + { + defaultMessage: 'API keys not enabled in Elasticsearch', + } + )} + + } + iconType="alert" + body={ +

+ + {i18n.translate( + 'xpack.apm.settings.agentKeys.apiKeysDisabledErrorLinkText', + { + defaultMessage: 'docs', + } + )} + + ), + }} + /> +

+ } + /> + ); +} diff --git a/x-pack/plugins/apm/public/components/app/Settings/agent_keys/prompts/permission_denied.tsx b/x-pack/plugins/apm/public/components/app/Settings/agent_keys/prompts/permission_denied.tsx new file mode 100644 index 0000000000000..bcac32bbaa3bc --- /dev/null +++ b/x-pack/plugins/apm/public/components/app/Settings/agent_keys/prompts/permission_denied.tsx @@ -0,0 +1,38 @@ +/* + * 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 { EuiEmptyPrompt } from '@elastic/eui'; +import React from 'react'; +import { i18n } from '@kbn/i18n'; + +export function PermissionDenied() { + return ( + + {i18n.translate( + 'xpack.apm.settings.agentKeys.noPermissionToManagelApiKeysTitle', + { + defaultMessage: 'You need permission to manage API keys', + } + )} + + } + body={ +

+ {i18n.translate( + 'xpack.apm.settings.agentKeys.noPermissionToManagelApiKeysDescription', + { + defaultMessage: 'Contact your system administrator', + } + )} +

+ } + /> + ); +} diff --git a/x-pack/plugins/apm/public/components/routing/settings/index.tsx b/x-pack/plugins/apm/public/components/routing/settings/index.tsx index e33f60e5593b0..45af7e62260b3 100644 --- a/x-pack/plugins/apm/public/components/routing/settings/index.tsx +++ b/x-pack/plugins/apm/public/components/routing/settings/index.tsx @@ -19,6 +19,7 @@ import { ApmIndices } from '../../app/Settings/ApmIndices'; import { CustomizeUI } from '../../app/Settings/customize_ui'; import { Schema } from '../../app/Settings/schema'; import { AnomalyDetection } from '../../app/Settings/anomaly_detection'; +import { AgentKeys } from '../../app/Settings/agent_keys'; function page({ path, @@ -132,6 +133,14 @@ export const settings = { element: , tab: 'anomaly-detection', }), + page({ + path: '/settings/agent-keys', + title: i18n.translate('xpack.apm.views.settings.agentKeys.title', { + defaultMessage: 'Agent keys', + }), + element: , + tab: 'agent-keys', + }), { path: '/settings', element: , diff --git a/x-pack/plugins/apm/public/components/routing/templates/settings_template.tsx b/x-pack/plugins/apm/public/components/routing/templates/settings_template.tsx index ecca2ddb07ec3..dabe9043495bc 100644 --- a/x-pack/plugins/apm/public/components/routing/templates/settings_template.tsx +++ b/x-pack/plugins/apm/public/components/routing/templates/settings_template.tsx @@ -21,7 +21,8 @@ type Tab = NonNullable[0] & { | 'anomaly-detection' | 'apm-indices' | 'customize-ui' - | 'schema'; + | 'schema' + | 'agent-keys'; hidden?: boolean; }; @@ -116,6 +117,17 @@ function getTabs({ }), href: getLegacyApmHref({ basePath, path: `/settings/schema`, search }), }, + { + key: 'agent-keys', + label: i18n.translate('xpack.apm.settings.agentKeys', { + defaultMessage: 'Agent Keys', + }), + href: getLegacyApmHref({ + basePath, + path: `/settings/agent-keys`, + search, + }), + }, ]; return tabs diff --git a/x-pack/plugins/apm/server/routes/agent_keys/get_agent_keys.ts b/x-pack/plugins/apm/server/routes/agent_keys/get_agent_keys.ts new file mode 100644 index 0000000000000..9c5b3e04c94f2 --- /dev/null +++ b/x-pack/plugins/apm/server/routes/agent_keys/get_agent_keys.ts @@ -0,0 +1,45 @@ +/* + * 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 { ApmPluginRequestHandlerContext } from '../typings'; +import { ApiKey } from '../../../../security/common/model'; + +export async function getAgentKeys({ + context, +}: { + context: ApmPluginRequestHandlerContext; +}) { + const body = { + size: 1000, + query: { + bool: { + filter: [ + { + term: { + 'metadata.application': 'apm', + }, + }, + ], + }, + }, + }; + + const esClient = context.core.elasticsearch.client; + const apiResponse = await esClient.asCurrentUser.transport.request<{ + api_keys: ApiKey[]; + }>({ + method: 'GET', + path: '_security/_query/api_key', + body, + }); + + const agentKeys = apiResponse.body.api_keys.filter( + ({ invalidated }) => !invalidated + ); + return { + agentKeys, + }; +} diff --git a/x-pack/plugins/apm/server/routes/agent_keys/get_agent_keys_privileges.ts b/x-pack/plugins/apm/server/routes/agent_keys/get_agent_keys_privileges.ts new file mode 100644 index 0000000000000..4aed9314f433c --- /dev/null +++ b/x-pack/plugins/apm/server/routes/agent_keys/get_agent_keys_privileges.ts @@ -0,0 +1,55 @@ +/* + * 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 { ApmPluginRequestHandlerContext } from '../typings'; +import { APMPluginStartDependencies } from '../../types'; + +interface SecurityHasPrivilegesResponse { + cluster: { + manage_security: boolean; + manage_api_key: boolean; + manage_own_api_key: boolean; + }; +} + +export async function getAgentKeysPrivileges({ + context, + securityPluginStart, +}: { + context: ApmPluginRequestHandlerContext; + securityPluginStart: NonNullable; +}) { + const [securityHasPrivilegesResponse, areApiKeysEnabled] = await Promise.all([ + context.core.elasticsearch.client.asCurrentUser.security.hasPrivileges( + { + body: { + cluster: ['manage_security', 'manage_api_key', 'manage_own_api_key'], + }, + } + ), + securityPluginStart.authc.apiKeys.areAPIKeysEnabled(), + ]); + + const { + body: { + cluster: { + manage_security: manageSecurity, + manage_api_key: manageApiKey, + manage_own_api_key: manageOwnApiKey, + }, + }, + } = securityHasPrivilegesResponse; + + const isAdmin = manageSecurity || manageApiKey; + const canManage = manageSecurity || manageApiKey || manageOwnApiKey; + + return { + areApiKeysEnabled, + isAdmin, + canManage, + }; +} diff --git a/x-pack/plugins/apm/server/routes/agent_keys/invalidate_agent_key.ts b/x-pack/plugins/apm/server/routes/agent_keys/invalidate_agent_key.ts new file mode 100644 index 0000000000000..e2f86298efdca --- /dev/null +++ b/x-pack/plugins/apm/server/routes/agent_keys/invalidate_agent_key.ts @@ -0,0 +1,29 @@ +/* + * 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 { ApmPluginRequestHandlerContext } from '../typings'; + +export async function invalidateAgentKey({ + context, + id, +}: { + context: ApmPluginRequestHandlerContext; + id: string; +}) { + const { + body: { invalidated_api_keys: invalidatedAgentKeys }, + } = await context.core.elasticsearch.client.asCurrentUser.security.invalidateApiKey( + { + body: { + ids: [id], + }, + } + ); + + return { + invalidatedAgentKeys, + }; +} diff --git a/x-pack/plugins/apm/server/routes/agent_keys/route.ts b/x-pack/plugins/apm/server/routes/agent_keys/route.ts new file mode 100644 index 0000000000000..e5f40205b2912 --- /dev/null +++ b/x-pack/plugins/apm/server/routes/agent_keys/route.ts @@ -0,0 +1,85 @@ +/* + * 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 Boom from '@hapi/boom'; +import { i18n } from '@kbn/i18n'; +import * as t from 'io-ts'; +import { createApmServerRoute } from '../apm_routes/create_apm_server_route'; +import { createApmServerRouteRepository } from '../apm_routes/create_apm_server_route_repository'; +import { getAgentKeys } from './get_agent_keys'; +import { getAgentKeysPrivileges } from './get_agent_keys_privileges'; +import { invalidateAgentKey } from './invalidate_agent_key'; + +const agentKeysRoute = createApmServerRoute({ + endpoint: 'GET /internal/apm/agent_keys', + options: { tags: ['access:apm'] }, + + handler: async (resources) => { + const { context } = resources; + const agentKeys = await getAgentKeys({ + context, + }); + + return agentKeys; + }, +}); + +const agentKeysPrivilegesRoute = createApmServerRoute({ + endpoint: 'GET /internal/apm/agent_keys/privileges', + options: { tags: ['access:apm'] }, + + handler: async (resources) => { + const { + plugins: { security }, + context, + } = resources; + + if (!security) { + throw Boom.internal(SECURITY_REQUIRED_MESSAGE); + } + + const securityPluginStart = await security.start(); + const agentKeysPrivileges = await getAgentKeysPrivileges({ + context, + securityPluginStart, + }); + + return agentKeysPrivileges; + }, +}); + +const invalidateAgentKeyRoute = createApmServerRoute({ + endpoint: 'POST /internal/apm/api_key/invalidate', + options: { tags: ['access:apm', 'access:apm_write'] }, + params: t.type({ + body: t.type({ id: t.string }), + }), + handler: async (resources) => { + const { context, params } = resources; + + const { + body: { id }, + } = params; + + const invalidatedKeys = await invalidateAgentKey({ + context, + id, + }); + + return invalidatedKeys; + }, +}); + +export const agentKeysRouteRepository = createApmServerRouteRepository() + .add(agentKeysRoute) + .add(agentKeysPrivilegesRoute) + .add(invalidateAgentKeyRoute); + +const SECURITY_REQUIRED_MESSAGE = i18n.translate( + 'xpack.apm.api.apiKeys.securityRequired', + { defaultMessage: 'Security plugin is required' } +); diff --git a/x-pack/plugins/apm/server/routes/apm_routes/get_global_apm_server_route_repository.ts b/x-pack/plugins/apm/server/routes/apm_routes/get_global_apm_server_route_repository.ts index ee4c9d1c8cfa5..1462e7540650a 100644 --- a/x-pack/plugins/apm/server/routes/apm_routes/get_global_apm_server_route_repository.ts +++ b/x-pack/plugins/apm/server/routes/apm_routes/get_global_apm_server_route_repository.ts @@ -37,6 +37,7 @@ import { APMRouteHandlerResources } from '../typings'; import { historicalDataRouteRepository } from '../historical_data'; import { eventMetadataRouteRepository } from '../event_metadata/route'; import { suggestionsRouteRepository } from '../suggestions/route'; +import { agentKeysRouteRepository } from '../agent_keys/route'; const getTypedGlobalApmServerRouteRepository = () => { const repository = createApmServerRouteRepository() @@ -64,7 +65,9 @@ const getTypedGlobalApmServerRouteRepository = () => { .merge(correlationsRouteRepository) .merge(fallbackToTransactionsRouteRepository) .merge(historicalDataRouteRepository) - .merge(eventMetadataRouteRepository); + .merge(eventMetadataRouteRepository) + .merge(eventMetadataRouteRepository) + .merge(agentKeysRouteRepository); return repository; };