-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Obs AI Assistant] Add security configs to API #201439
[Obs AI Assistant] Add security configs to API #201439
Conversation
/ci |
feebf41
to
06f85fb
Compare
Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant) |
db33865
to
ea97495
Compare
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
ea97495
to
97a7965
Compare
@@ -146,7 +146,7 @@ export class ObservabilityPlugin implements Plugin<ObservabilityPluginSetup> { | |||
all: { | |||
app: [observabilityFeatureId], | |||
catalogue: [observabilityFeatureId], | |||
api: ['rac'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh, does this mean they never worked before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Earlier we didn't have any access privilege specified for this API. So it worked before too as far as I know (and from my testing before adding the feature privilege).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm I actually thought tags
were used for this purpose, but I'm not sure if we tested it in any case. Do you mind adding an API test that checks if there's a 403 when using a user with insufficient access privileges?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, now I get it, this is for the Observability plugin. Hmm. I think the outcome of this should be that you only have access to this API if you have the Obs AI Assistant feature privilege. With this change, is that the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's my understanding @dgieselaar
I added an API tests - https://github.com/elastic/kibana/pull/201439/files#diff-e1c9265ab37c43c162cde67fef054bdc1a734737e03b3fd346ce4be96bbdbb30R517
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, what I mean is that the feature privilege for the AI Assistant is defined here:
kibana/x-pack/plugins/observability_solution/observability_ai_assistant/server/plugin.ts
Line 80 in c46d94c
api: [OBSERVABILITY_AI_ASSISTANT_FEATURE_ID, 'ai_assistant', 'manage_llm_product_doc'], |
If the user has this privilege, they should have access to /internal/observability/assistant/alert_details_contextual_insights
. If they don't have this privilege, they shouldn't. If I understand this PR correctly, you're changing a different feature privilege?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm adding the same feature privilege (ai_assistant
) to the contextual details endpoint. With the new authz migration, options.tags
are not used anymore. It's added under the security.authz.requiredPrivileges
property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
access: 'internal', | ||
}, | ||
security: { | ||
authz: { | ||
requiredPrivileges: ['ai_assistant', 'rac'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: removed rac
because this error happens on the main
branch too, therefore not related to authz
updates.
I added rac
here, because I saw the below error:
[2024-11-25T16:42:54.842-05:00][ERROR][plugins.apm] Error while fetching observability alert details context
[2024-11-25T16:42:54.842-05:00][ERROR][plugins.apm] Error: Insufficient privileges to access feature
at /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/ml/server/lib/capabilities/check_capabilities.ts:64:13
at getApmServiceSummary (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_apm_service_summary/index.ts:75:11)
at getAnomalies (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_apm_service_summary/get_anomalies.ts:24:28)
at getApmServiceSummary (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_apm_service_summary/index.ts:67:39)
at /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_observability_alert_details_context/index.ts:101:88
at /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_observability_alert_details_context/index.ts:272:22
at /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_observability_alert_details_context/index.ts:270:50
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability/server/services/index.ts:49:16
at async AlertDetailsContextualInsightsService.getAlertDetailsContext (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability/server/services/index.ts:47:21)
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:174:20
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:297:97
at async getAlertGroupDetails (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:296:30)
at async getAlertsContext (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:306:73)
at async executor (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:173:25)
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/actions/server/lib/action_executor.ts:395:21
at async ActionExecutor.execute (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/actions/server/lib/action_executor.ts:77:12)
at async Object.run (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/actions/server/lib/task_runner_factory.ts:91:28)
at async TaskManagerRunner.run (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/task_manager/server/task_running/task_runner.ts:325:22)
at /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_observability_alert_details_context/index.ts:74:54
at /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_observability_alert_details_context/index.ts:74:54
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability/server/services/index.ts:49:16
at async AlertDetailsContextualInsightsService.getAlertDetailsContext (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability/server/services/index.ts:47:21)
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:174:20
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:297:97
at async getAlertGroupDetails (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:296:30)
at async getAlertsContext (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:306:73)
at async executor (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:173:25)
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/actions/server/lib/action_executor.ts:395:21
at async ActionExecutor.execute (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/actions/server/lib/action_executor.ts:77:12)
at async Object.run (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/actions/server/lib/task_runner_factory.ts:91:28)
at async TaskManagerRunner.run (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/task_manager/server/task_running/task_runner.ts:325:22)
at /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_observability_alert_details_context/index.ts:69:118
at Object.getScopedLogSourcesService (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/logs_data_access/server/services/log_sources_service/index.ts:40:37)
at /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_observability_alert_details_context/index.ts:69:118
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability/server/services/index.ts:49:16
at async AlertDetailsContextualInsightsService.getAlertDetailsContext (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability/server/services/index.ts:47:21)
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:174:20
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:297:97
at async getAlertGroupDetails (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:296:30)
at async getAlertsContext (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:306:73)
at async executor (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability_ai_assistant_app/server/rule_connector/index.ts:173:25)
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/actions/server/lib/action_executor.ts:395:21
at async ActionExecutor.execute (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/actions/server/lib/action_executor.ts:77:12)
at async Object.run (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/actions/server/lib/task_runner_factory.ts:91:28)
at async TaskManagerRunner.run (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/task_manager/server/task_running/task_runner.ts:325:22)
at /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_observability_alert_details_context/index.ts:69:75
at Object.start (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/plugin.ts:88:46)
at /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/apm/server/routes/assistant_functions/get_observability_alert_details_context/index.ts:69:75
at async /Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability/server/services/index.ts:49:16
at async AlertDetailsContextualInsightsService.getAlertDetailsContext (/Users/viduni/Workspace/Elastic/kibana/x-pack/plugins/observability_solution/observability/server/services/index.ts:47:21)
access: 'internal', | ||
}, | ||
security: { | ||
authz: { | ||
requiredPrivileges: ['ai_assistant', 'rac'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is ai_assistant
a privilege? I'd expect something like ai_assistant_contextual_details:read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the below, ai_assistant
is a privilege:
kibana/x-pack/plugins/observability_solution/observability_ai_assistant/server/plugin.ts
Line 80 in c46d94c
api: [OBSERVABILITY_AI_ASSISTANT_FEATURE_ID, 'ai_assistant', 'manage_llm_product_doc'], |
It's the same as options.tags
we've had before:
kibana/x-pack/plugins/observability_solution/observability_ai_assistant/server/routes/chat/route.ts
Line 130 in c46d94c
tags: ['access:ai_assistant'], |
7b9356e
to
00db57c
Compare
…n't access the API
c0f46cf
to
4bebb68
Compare
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]
History
cc @viduni94 |
Starting backport for target branches: 8.x |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
The streams app plugin backport PR needs to be merged first for me to backport this PR. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
5 similar comments
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Friendly reminder: Looks like this PR hasn’t been backported yet. |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary ### Problem The API `/internal/observability/assistant/alert_details_contextual_insights` does not provide explicit authorization settings. ### Solution Add access privileges (`ai_assistant`) to the above API ### Checklist - [x] [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 - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) (cherry picked from commit 650c5ca)
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
# Backport This will backport the following commits from `main` to `8.x`: - [[Obs AI Assistant] Add security configs to API (#201439)](#201439) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Viduni Wickramarachchi","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-28T17:20:31Z","message":"[Obs AI Assistant] Add security configs to API (#201439)\n\n## Summary\r\n\r\n### Problem\r\nThe API\r\n`/internal/observability/assistant/alert_details_contextual_insights`\r\ndoes not provide explicit authorization settings.\r\n\r\n### Solution\r\nAdd access privileges (`ai_assistant`) to the above API\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"650c5ca2122168b6e717e588d3b294bbd8e663ad","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["enhancement","release_note:skip","backport missing","v9.0.0","Team:Obs AI Assistant","ci:project-deploy-observability","Team:obs-ux-management","backport:version","Authz: API migration","v8.18.0"],"number":201439,"url":"https://github.com/elastic/kibana/pull/201439","mergeCommit":{"message":"[Obs AI Assistant] Add security configs to API (#201439)\n\n## Summary\r\n\r\n### Problem\r\nThe API\r\n`/internal/observability/assistant/alert_details_contextual_insights`\r\ndoes not provide explicit authorization settings.\r\n\r\n### Solution\r\nAdd access privileges (`ai_assistant`) to the above API\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"650c5ca2122168b6e717e588d3b294bbd8e663ad"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201439","number":201439,"mergeCommit":{"message":"[Obs AI Assistant] Add security configs to API (#201439)\n\n## Summary\r\n\r\n### Problem\r\nThe API\r\n`/internal/observability/assistant/alert_details_contextual_insights`\r\ndoes not provide explicit authorization settings.\r\n\r\n### Solution\r\nAdd access privileges (`ai_assistant`) to the above API\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] The PR description includes the appropriate Release Notes section,\r\nand the correct `release_note:*` label is applied per the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"650c5ca2122168b6e717e588d3b294bbd8e663ad"}},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
## Summary ### Problem The API `/internal/observability/assistant/alert_details_contextual_insights` does not provide explicit authorization settings. ### Solution Add access privileges (`ai_assistant`) to the above API ### Checklist - [x] [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 - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
Summary
Problem
The API
/internal/observability/assistant/alert_details_contextual_insights
does not provide explicit authorization settings.Solution
Add access privileges (
ai_assistant
) to the above APIChecklist
release_note:*
label is applied per the guidelines