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

[ML] Categorization examples privilege check #57375

Conversation

jgowdyelastic
Copy link
Member

@jgowdyelastic jgowdyelastic commented Feb 11, 2020

Changes the categorization_field_examples endpoint so when it calls _analyse to retrieve the tokens, it does so as the kibana internal user.
Because of this change, the endpoint also now requires the user to have job creation privileges.
The endpoint returns a 403 if this requirement is not met.

Relates to elastic/elasticsearch#51391
cc @droberts195

Checklist

For maintainers

@jgowdyelastic jgowdyelastic force-pushed the categorization-examples-privilege-check branch 2 times, most recently from abfd38c to 9db4c01 Compare February 12, 2020 10:20
@jgowdyelastic jgowdyelastic self-assigned this Feb 12, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@jgowdyelastic jgowdyelastic marked this pull request as ready for review February 12, 2020 11:17
@jgowdyelastic jgowdyelastic requested a review from a team as a code owner February 12, 2020 11:17
Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

A typo, but otherwise code LGTM

droberts195 added a commit to droberts195/elasticsearch that referenced this pull request Feb 12, 2020
This is to support the ML categorization wizard.

Currently cluster:admin/analyze is only provided with the
"manage" cluster privilege, which is an excessive privilege
level to provide access to this single feature.  It means
that the ML categorization wizard only works for extremely
highly privileged users.

Following this change the Kibana system user will be
permitted to run the _analyze endpoint on supplied strings
(not on an index).  The ML UI will then call the _analyze
endpoint as the Kibana system user after first checking
that the logged-in user is permitted to create an ML job.
This will mean that users with the more reasonable
"manage_ml" cluster privilege will be permitted to use
the ML categorization wizard.

(This is also consistent with the way the ML UI will access
_all_ Elasticsearch functionality when the "ML in Spaces"
project is completed.)

Closes elastic#51391
Relates elastic/kibana#57375
@droberts195
Copy link
Contributor

The corresponding Elasticsearch change is elastic/elasticsearch#52259. Please wait for that to be merged before merging this change.

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

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

LGTM

@jgowdyelastic
Copy link
Member Author

retest

return true;
}

const resp = await callWithRequest('ml.privilegeCheck', {
Copy link
Contributor

Choose a reason for hiding this comment

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

As an alternative to doing the privilege check using the _has_privileges API, you can augment the reserved privilege which is assigned to both the machine_learning_admin and machine_learning_user roles and take advantage of the "API Authorization" similar to this example: https://www.elastic.co/guide/en/kibana/current/development-plugin-feature-registration.html#_example_2_dev_tools

Copy link
Member Author

Choose a reason for hiding this comment

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

Have spoken to @kobelb and have agreed to leave this as is for now as upcoming spaces work will see the replacement of all privilege checks in ML.

droberts195 added a commit to elastic/elasticsearch that referenced this pull request Feb 13, 2020
This is to support the ML categorization wizard.

Currently cluster:admin/analyze is only provided with the
"manage" cluster privilege, which is an excessive privilege
level to provide access to this single feature.  It means
that the ML categorization wizard only works for extremely
highly privileged users.

Following this change the Kibana system user will be
permitted to run the _analyze endpoint on supplied strings
(not on an index).  The ML UI will then call the _analyze
endpoint as the Kibana system user after first checking
that the logged-in user is permitted to create an ML job.
This will mean that users with the more reasonable
"manage_ml" cluster privilege will be permitted to use
the ML categorization wizard.

(This is also consistent with the way the ML UI will access
_all_ Elasticsearch functionality when the "ML in Spaces"
project is completed.)

Closes #51391
Relates elastic/kibana#57375
droberts195 added a commit to elastic/elasticsearch that referenced this pull request Feb 13, 2020
This is to support the ML categorization wizard.

Currently cluster:admin/analyze is only provided with the
"manage" cluster privilege, which is an excessive privilege
level to provide access to this single feature.  It means
that the ML categorization wizard only works for extremely
highly privileged users.

Following this change the Kibana system user will be
permitted to run the _analyze endpoint on supplied strings
(not on an index).  The ML UI will then call the _analyze
endpoint as the Kibana system user after first checking
that the logged-in user is permitted to create an ML job.
This will mean that users with the more reasonable
"manage_ml" cluster privilege will be permitted to use
the ML categorization wizard.

(This is also consistent with the way the ML UI will access
_all_ Elasticsearch functionality when the "ML in Spaces"
project is completed.)

Closes #51391
Relates elastic/kibana#57375
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 left a comment

Choose a reason for hiding this comment

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

LGTM ⚡️

@jgowdyelastic jgowdyelastic force-pushed the categorization-examples-privilege-check branch from 2dd8218 to fd5e62a Compare February 14, 2020 08:49
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 left a comment

Choose a reason for hiding this comment

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

Latest edits LGTM ⚡️

@jgowdyelastic jgowdyelastic force-pushed the categorization-examples-privilege-check branch from d51ffb4 to af4da4f Compare February 14, 2020 16:02
@jgowdyelastic
Copy link
Member Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

  • 💔 Build #26779 failed d51ffb42cf29199a39e14198f29439cc5713efe5
  • 💔 Build #26759 failed 6ac04589199bb70dd77f9989069fefd73b042f3e
  • 💚 Build #26207 succeeded 2dd82182cefda02c799406e5078090d3ab12356c
  • 💚 Build #26145 succeeded d02c5a3bc5e0b7b1ef1b03958a0aa2f50cebc792
  • 💚 Build #26131 succeeded b49ef18174c3bed37030dee779fb4419626db732

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@jgowdyelastic jgowdyelastic merged commit 5452400 into elastic:master Feb 17, 2020
@jgowdyelastic jgowdyelastic deleted the categorization-examples-privilege-check branch February 17, 2020 10:47
jgowdyelastic added a commit to jgowdyelastic/kibana that referenced this pull request Feb 17, 2020
* [ML] Categorization examples privilege check

* adding privileges check to endpoint

* fixing typo

* moving privilege check to router

* removing unused variable

* rebasing master

* removing comment

Co-authored-by: Elastic Machine <[email protected]>
jgowdyelastic added a commit that referenced this pull request Feb 17, 2020
* [ML] Categorization examples privilege check

* adding privileges check to endpoint

* fixing typo

* moving privilege check to router

* removing unused variable

* rebasing master

* removing comment

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants