Skip to content
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

[index management] Allow view only access to Index Templates, Component Templates and Enrich policies #195162

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

mattkime
Copy link
Contributor

@mattkime mattkime commented Oct 5, 2024

Summary

Previously, Index Templates, Component Templates and Enrich policies failed to provide view access. This has been addressed by removing endpoints that were used for edit privilege checks and replacing them capabilities api usage only around editing features.

Closes #178654

@mattkime mattkime self-assigned this Nov 3, 2024
@mattkime mattkime changed the title remove use of api endpoint for privileges check [index management] Allow view only access to Index Templates, Component Templates and Enrich policies Nov 4, 2024
@mattkime mattkime added backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Index Management Index and index templates UI Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages release_note:fix labels Nov 4, 2024
@mattkime mattkime marked this pull request as ready for review November 17, 2024 04:52
@mattkime mattkime requested review from a team as code owners November 17, 2024 04:52
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #28 / serverless search UI Elasticsearch Start [Onboarding Empty State] developer should show the api key in code view

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
indexManagement 695 690 -5

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
indexManagement 689.9KB 687.8KB -2.1KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
indexManagement 46.1KB 45.8KB -218.0B

History

cc @mattkime

@elastic elastic deleted a comment from kibana-ci Nov 17, 2024
@mattkime
Copy link
Contributor Author

/ci

Copy link
Member

@dmlemeshko dmlemeshko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x-pack/test/functional/config.base.js changes LGTM

@sabarasaba sabarasaba self-requested a review November 18, 2024 12:00
Copy link
Member

@sabarasaba sabarasaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work @mattkime! Tested locally and all works well. I do however have something I'd like to discuss as part of these new changes:

The missing privileges callout we used to have was very concise copy wise and will tell exactly what privilege(s) the user was missing

Screenshot 2024-11-19 at 10 48 26

Whereas right now the error we show to them it's not as friendly, gives information that might not be relevant to them (current user, action) and it doesn't also specifically say which privileges they are missing.. just which ones are required.

Screenshot 2024-11-19 at 10 17 04

Is there anyway we can extract some of the information from the error and perhaps have a more user friendly copy?

@@ -79,7 +77,7 @@ const ListView: React.FunctionComponent<RouteComponentProps> = ({ history, locat
return <ErrorState error={error} resendRequest={reloadPolicies} />;
}

if (policies?.length === 0) {
if (capabilities.index_management.manageEnrich && policies?.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change we lose the empty state if they dont have the right permissions, how about we remove the CTA in the empty state component instead?

</EuiButton>,
];

if (capabilities.index_management.manageEnrich) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought:

We are passing the capabilities object in quite a few places and accessing its internal keys in order to figure out if the user has the manageEnrich privilege. I think having a computed property in the app context (something like hasManageEnrichPrivilege) would avoid us having to specify the full path everywhere and perhaps also be a little bit more semantic than capabilities.index_management.manageEnrich. It might also simplify test setup as we would only need to mock a boolean instead of a full dependency.

Also, a bit unlikely I guess, but if this permission path were to change we would also have to replace it in a bunch of files rather than just once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Index Management Index and index templates UI Feature:Kibana Management Feature label for Data Views, Advanced Setting, Saved Object management pages release_note:fix
Projects
None yet
4 participants