-
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
[Discover] Do not update defaultIndex in case of insufficient permissions #134202
[Discover] Do not update defaultIndex in case of insufficient permissions #134202
Conversation
…cloud_security_posture plugin (elastic#130630)
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
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.
The issue is still present for Dashboard and Visualize apps.
const patterns = await this.getIdsWithTitle(); | ||
let defaultId: string | undefined = await this.config.get('defaultIndex'); | ||
const exists = defaultId ? patterns.some((pattern) => pattern.id === defaultId) : false; | ||
|
||
if (defaultId && !exists) { | ||
await this.config.remove('defaultIndex'); | ||
if (update) { |
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.
It could be better here to check user's write-rights before trying to modify the settings. Do we have such API?
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.
that's a good question, @mattkime, can we? of course this would be a better pattern. What we did currently in Discover is, preventing to set the value in config, because it's not necessary in our domain.
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.
Could we use capabilities.advangedSettings.save
?
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.
@jughosta yes, thx, we should! I've refactored it to check for permissions, instead of adding another param to the function. This way, it also should work for other consumers of this functionality (Dashboard ...) ... let's see, if CI agrees
Yes, we can be sure that it works in Discover, but e.g in has to be set |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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.
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'd rather see the defaultIndex value updated with a system level privileged but I'm not sure thats possible right now so 🚢 it!
Oh, I'd like to see getCanSaveAdvancedSettings
marked private before this is merged
/** | ||
* Can the user save advanced settings? | ||
*/ | ||
public getCanSaveAdvancedSettings: () => Promise<boolean>; |
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.
This should be private, as its only use is internal to getDefaultDataView
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.
@mattkime I did but now TypeScript is complaining, can you help
property 'getCanSaveAdvancedSettings' is private in type 'DataViewsServicePublic' but not in type 'DataViewsServicePublic'.
85042cf
to
cab0d7f
Compare
💚 Build SucceededMetrics [docs]Page load bundle
History
To update your PR or re-run it, just comment with: cc @kertal |
@mattkime :) so simple! Thx! |
Summary
This PR prevents Discover from updating the
defaultIndex
uiSettings which can lead to a 403 error message when the user doesn't have permissions.getDefaultDataView
ofDataViewsService
returns the neededdefaultIndex
also without updating, when the user has insufficient permissions. Works also in Dashboard, Visualizations ...Testing
defaultIndex
value in Advanced settings.Fixes #46124
Checklist