From 67375d6e3b8862b64467fbe9f1b9d317e34fdd40 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 29 Oct 2024 19:10:25 +0000 Subject: [PATCH] [Authz] Migrated authorized routes owned by @elastic/security-generative-ai --- .../routes/anonymization_fields/bulk_actions_route.ts | 6 +++++- .../server/routes/anonymization_fields/find_route.ts | 6 ++++-- .../routes/attack_discovery/get/get_attack_discovery.ts | 6 ++++-- .../attack_discovery/post/cancel/cancel_attack_discovery.ts | 6 ++++-- .../routes/attack_discovery/post/post_attack_discovery.ts | 6 +++++- .../server/routes/capabilities/get_capabilities_route.ts | 6 ++++-- .../server/routes/chat/chat_complete_route.ts | 6 ++++-- .../server/routes/evaluate/get_evaluate.ts | 6 ++++-- .../server/routes/evaluate/post_evaluate.ts | 6 +++++- .../server/routes/knowledge_base/delete_knowledge_base.ts | 6 ++++-- .../routes/knowledge_base/entries/bulk_actions_route.ts | 6 +++++- .../server/routes/knowledge_base/entries/create_route.ts | 6 ++++-- .../server/routes/knowledge_base/entries/find_route.ts | 6 ++++-- .../routes/knowledge_base/get_knowledge_base_status.ts | 6 ++++-- .../server/routes/knowledge_base/post_knowledge_base.ts | 6 +++++- .../server/routes/post_actions_connector_execute.ts | 6 ++++-- .../server/routes/prompts/bulk_actions_route.ts | 6 +++++- .../elastic_assistant/server/routes/prompts/find_route.ts | 6 ++++-- .../append_conversation_messages_route.ts | 6 ++++-- .../server/routes/user_conversations/bulk_actions_route.ts | 6 +++++- .../server/routes/user_conversations/create_route.ts | 6 ++++-- .../server/routes/user_conversations/delete_route.ts | 6 ++++-- .../server/routes/user_conversations/find_route.ts | 6 ++++-- .../server/routes/user_conversations/read_route.ts | 6 ++++-- .../server/routes/user_conversations/update_route.ts | 6 ++++-- 25 files changed, 107 insertions(+), 43 deletions(-) diff --git a/x-pack/plugins/elastic_assistant/server/routes/anonymization_fields/bulk_actions_route.ts b/x-pack/plugins/elastic_assistant/server/routes/anonymization_fields/bulk_actions_route.ts index 5464756739c08..dce2687add193 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/anonymization_fields/bulk_actions_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/anonymization_fields/bulk_actions_route.ts @@ -120,8 +120,12 @@ export const bulkActionAnonymizationFieldsRoute = ( .post({ access: 'public', path: ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL_BULK_ACTION, + security: { + authz: { + requiredPrivileges: ['securitySolution-updateAIAssistantAnonymization'], + }, + }, options: { - tags: ['access:securitySolution-updateAIAssistantAnonymization'], timeout: { idleSocket: moment.duration(15, 'minutes').asMilliseconds(), }, diff --git a/x-pack/plugins/elastic_assistant/server/routes/anonymization_fields/find_route.ts b/x-pack/plugins/elastic_assistant/server/routes/anonymization_fields/find_route.ts index 904a80d6a3ea4..30c52d004abb0 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/anonymization_fields/find_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/anonymization_fields/find_route.ts @@ -32,8 +32,10 @@ export const findAnonymizationFieldsRoute = ( .get({ access: 'public', path: ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL_FIND, - options: { - tags: ['access:elasticAssistant'], + security: { + authz: { + requiredPrivileges: ['elasticAssistant'], + }, }, }) .addVersion( diff --git a/x-pack/plugins/elastic_assistant/server/routes/attack_discovery/get/get_attack_discovery.ts b/x-pack/plugins/elastic_assistant/server/routes/attack_discovery/get/get_attack_discovery.ts index e3756b10a3fb3..9049c152183b0 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/attack_discovery/get/get_attack_discovery.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/attack_discovery/get/get_attack_discovery.ts @@ -24,8 +24,10 @@ export const getAttackDiscoveryRoute = (router: IRouter .post({ access: 'internal', path: ELASTIC_AI_ASSISTANT_KNOWLEDGE_BASE_URL, + security: { + authz: { + requiredPrivileges: ['elasticAssistant'], + }, + }, options: { - tags: ['access:elasticAssistant'], timeout: { idleSocket: ROUTE_HANDLER_TIMEOUT, }, diff --git a/x-pack/plugins/elastic_assistant/server/routes/post_actions_connector_execute.ts b/x-pack/plugins/elastic_assistant/server/routes/post_actions_connector_execute.ts index 4b65b5bb3f1e5..5edb406a02169 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/post_actions_connector_execute.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/post_actions_connector_execute.ts @@ -39,8 +39,10 @@ export const postActionsConnectorExecuteRoute = ( .post({ access: 'internal', path: POST_ACTIONS_CONNECTOR_EXECUTE, - options: { - tags: ['access:elasticAssistant'], + security: { + authz: { + requiredPrivileges: ['elasticAssistant'], + }, }, }) .addVersion( diff --git a/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts b/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts index 44a949cd22eeb..86018190e93cc 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts @@ -114,8 +114,12 @@ export const bulkPromptsRoute = (router: ElasticAssistantPluginRouter, logger: L .post({ access: 'public', path: ELASTIC_AI_ASSISTANT_PROMPTS_URL_BULK_ACTION, + security: { + authz: { + requiredPrivileges: ['elasticAssistant'], + }, + }, options: { - tags: ['access:elasticAssistant'], timeout: { idleSocket: moment.duration(15, 'minutes').asMilliseconds(), }, diff --git a/x-pack/plugins/elastic_assistant/server/routes/prompts/find_route.ts b/x-pack/plugins/elastic_assistant/server/routes/prompts/find_route.ts index 848680be662a3..44680595b0923 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/prompts/find_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/prompts/find_route.ts @@ -25,8 +25,10 @@ export const findPromptsRoute = (router: ElasticAssistantPluginRouter, logger: L .get({ access: 'public', path: ELASTIC_AI_ASSISTANT_PROMPTS_URL_FIND, - options: { - tags: ['access:elasticAssistant'], + security: { + authz: { + requiredPrivileges: ['elasticAssistant'], + }, }, }) .addVersion( diff --git a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/append_conversation_messages_route.ts b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/append_conversation_messages_route.ts index 796c0d617fe5d..1ead7b94b31b9 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/append_conversation_messages_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/append_conversation_messages_route.ts @@ -24,8 +24,10 @@ export const appendConversationMessageRoute = (router: ElasticAssistantPluginRou .post({ access: 'internal', path: ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BY_ID_MESSAGES, - options: { - tags: ['access:elasticAssistant'], + security: { + authz: { + requiredPrivileges: ['elasticAssistant'], + }, }, }) .addVersion( diff --git a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/bulk_actions_route.ts b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/bulk_actions_route.ts index 6e30acb1a47c7..f6f23d2fd633d 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/bulk_actions_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/bulk_actions_route.ts @@ -118,8 +118,12 @@ export const bulkActionConversationsRoute = ( .post({ access: 'internal', path: ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BULK_ACTION, + security: { + authz: { + requiredPrivileges: ['elasticAssistant'], + }, + }, options: { - tags: ['access:elasticAssistant'], timeout: { idleSocket: moment.duration(15, 'minutes').asMilliseconds(), }, diff --git a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts index b92ad5462963e..e649cde3a6945 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/create_route.ts @@ -25,8 +25,10 @@ export const createConversationRoute = (router: ElasticAssistantPluginRouter): v access: 'public', path: ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL, - options: { - tags: ['access:elasticAssistant'], + security: { + authz: { + requiredPrivileges: ['elasticAssistant'], + }, }, }) .addVersion( diff --git a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/delete_route.ts b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/delete_route.ts index 5d761c09f682c..d907ceaed535a 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/delete_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/delete_route.ts @@ -21,8 +21,10 @@ export const deleteConversationRoute = (router: ElasticAssistantPluginRouter) => .delete({ access: 'public', path: ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BY_ID, - options: { - tags: ['access:elasticAssistant'], + security: { + authz: { + requiredPrivileges: ['elasticAssistant'], + }, }, }) .addVersion( diff --git a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/find_route.ts b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/find_route.ts index e7ce80039beb0..96072139c5d17 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/find_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/find_route.ts @@ -28,8 +28,10 @@ export const findUserConversationsRoute = (router: ElasticAssistantPluginRouter) .get({ access: 'public', path: ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_FIND, - options: { - tags: ['access:elasticAssistant'], + security: { + authz: { + requiredPrivileges: ['elasticAssistant'], + }, }, }) .addVersion( diff --git a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/read_route.ts b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/read_route.ts index dd540897b0ece..5c0dba399e519 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/read_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/read_route.ts @@ -23,8 +23,10 @@ export const readConversationRoute = (router: ElasticAssistantPluginRouter) => { .get({ access: 'public', path: ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BY_ID, - options: { - tags: ['access:elasticAssistant'], + security: { + authz: { + requiredPrivileges: ['elasticAssistant'], + }, }, }) .addVersion( diff --git a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/update_route.ts b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/update_route.ts index 4ad819ef0caa0..b6af3d3412fd4 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/user_conversations/update_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/user_conversations/update_route.ts @@ -26,8 +26,10 @@ export const updateConversationRoute = (router: ElasticAssistantPluginRouter) => .put({ access: 'public', path: ELASTIC_AI_ASSISTANT_CONVERSATIONS_URL_BY_ID, - options: { - tags: ['access:elasticAssistant'], + security: { + authz: { + requiredPrivileges: ['elasticAssistant'], + }, }, }) .addVersion(