-
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
[data views] Rely on Content Management / Saved Object client for API security, don't use capabilities API #188596
base: main
Are you sure you want to change the base?
Conversation
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.
In general the code changes look good, but I'm not exactly sure how/what to test. Could you provide instructions on how to test the differences? Or maybe we could add a functional or API integration test to validate the impact of these changes?
@@ -844,7 +855,7 @@ describe('IndexPatterns', () => { | |||
|
|||
test('dont set defaultIndex without capability allowing advancedSettings save', async () => { |
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 this description still accurate for this test if we no longer rely on capabilities 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.
The advanced settings and therefore the default data view rely on the capabilites API, therefore the test is still relevant.
Co-authored-by: Davis McPhee <davismcphee@hotmail.com>
@elasticmachine merge upstream @mattkime ,seems this was somehow paused, will you iterate on it? |
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.
.buildkite/ftr_platform_stateful_configs.yml
/ci |
/ci |
1 similar comment
/ci |
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.
Code changes look good, and I confirmed I was able to create, update, and delete a data view in a space where indexPatterns
was disabled. It looks like there are just a couple of test failures to look into, then I'll approve for merge.
@@ -1220,9 +1220,6 @@ export class DataViewsService { | |||
*/ | |||
|
|||
async createSavedObject(dataView: AbstractDataView, overwrite = false) { | |||
if (!(await this.getCanSave())) { |
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.
Can getCanSave
be dropped entirely? It doesn't look like it's used anywhere anymore.
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.
Its used externally, particularly in UIs
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.
Are you sure about this? I did a global search across the codebase and the only remaining references I've found are related to its initialization within the data views plugin:
Possibly I'm missing something here though about how this is used. Not a blocker on my end regardless, just something to consider.
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.
@davismcphee - you're correct, I was confusing it with the sync version of the function. I might as well remove it, pending the conversation with Larry below.
/ci |
💔 Build FailedFailed CI StepsTest Failures
Metrics [docs]Page load bundle
History
To update your PR or re-run it, just comment with: cc @mattkime |
@mattkime , I took a look at the investigations Cypress tests that is failing. So below is the summary of test. Now in this PR the error is gone with the same priveleges. Is it expected from your side? This seems to be a bug. A user without Saved object Management should be getting
|
@legrego We had discussed how the data views api should rely on the saved object client for auth and didn't need to check the capabilities API. The saved objects tagging api is apparently affected by spaces (and therefore the capabilities api) - is there a contradiction here? |
@mattkime thanks for the ping.
That's not entirely accurate. A user still needs to be authorized to perform a specific
Where is tagging using the capabilities API? I'm also confused by the test failure -- how/why is the tagging API impacted by this change to the data views API? In general: UI Capabilities should only be used to inform the front-end if a particular action is currently available. An action could be unavailable for several reasons: You capabilities API will not tell you why a feature isn't available, as it's a simple Protecting access to saved objects should be done through the SO privilege declarations during feature registration (e.g., Discover grants kibana/x-pack/plugins/features/server/oss_features.ts Lines 36 to 45 in 64e1116
|
Its not, its brought up for comparison. Frankly I'm getting a little lost. It seems clear that my removal of the capabilities check was the right move - it seems this should be accompanied by a behavior change otherwise this would have never come to my attention. Here's the issue created by the customer - #187540 At this point its unclear to me what should be happening and how it should be implemented. |
I agree.
I think the desired behavior change is illustrated by your new API test in |
@logeekal Lets find some time to talk about the privileges provided to the user in that test and how the error is being used. |
Sure @mattkime , sent you an invite for Wednesday. It was the earliest time I could find. feel free to suggest me any other time. |
Hey @mattkime, @michaelolo24 I can confirm that error is coming in Security -> DataViews But this Error is not raised with the new code here, although it should.
According to your above statement @mattkime, looks like |
Summary
The capabilities api should only be used for UI features and specifically not REST CRUD operations.
In particular, it should be possible to perform CRUD operations even without access to a particular space.
Closes #188569
Functional test is based on #187540