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

Add built-in user and role for code plugin #37030

Merged
merged 5 commits into from
Jan 24, 2019

Conversation

spacedragon
Copy link
Contributor

This pr add a code_system as a reserved role, and grant index privilege .code-* to both code_system and kibana_system.

@javanna javanna added the :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC label Dec 31, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security

@zfy0701 zfy0701 requested review from polyfractal and spalger January 3, 2019 02:46
@zfy0701
Copy link

zfy0701 commented Jan 3, 2019

@spalger @polyfractal could you help reviewing this PR?

@tvernum
Copy link
Contributor

tvernum commented Jan 3, 2019

Why are we creating a new role, but not a new user? How will the code_system role be used?

@spacedragon
Copy link
Contributor Author

spacedragon commented Jan 3, 2019

@tvernum By default, the kibana user has sufficient permissions to manage code plugins, but if a customer wants to grant other users permission to manage code, they can assign code_system to them.

@polyfractal
Copy link
Contributor

@tvernum would you mind taking the review on this? Not sure I know enough about security to intelligently review past syntax/style :)

@tvernum
Copy link
Contributor

tvernum commented Jan 4, 2019

I will review, but I'll be out for the next couple of days, so I won't get to it until mid next week.

It would be helpful if you could provide some background about how you intend for this to work. I can review the change at a purely technical level, but in order to understand whether it's the right change to be making I'll need to understand what these .code* indices are used for and which users/applications read/write to them.
At the moment I'm confused by the fact that we're changing the kibana_system user (which the Kibana backend uses) and creating a code_admin user (which seems to be intended for real people). They seem very different and I'm not sure how they fit together.

Also, before I can approve this, we'll need corresponding changes to ReservedRolesStoreTests.

@zfy0701
Copy link

zfy0701 commented Jan 4, 2019

so we are trying to follow how beats/apm/monitoring security works in Kibana

first, the kibana_system role would have read/write access to all code-* indices because it's the root role. since it has access to monitoring/reporting indices so we assume we should do the same. There is some background process we run inside kibana that need to read/write to code-* indices.

then, for users that are not root user but need to have permission to manage code, they need to be granted code_admin role that read/writes code indices, this is similar to beats_admin I assume

last, for normal users, they need to be granted read access to all code-* indices, we initially planned to create a code_user role, but it's seems beats and apm don't do that, so we just follow the pattern.

Please let us known if we have misunderstood how beats/apm works in Kibana, it would be super helpful.

@tvernum
Copy link
Contributor

tvernum commented Jan 10, 2019

Thanks for the explanation @zfy0701.

Is .code-* really the index pattern you want for the admin role? I don't know your backend implementation so it's hard for me to tell, but it surprises me that an admin would be expected to have write access to all of the code-search indices. Wouldn't they typically be storing parsed representations of the code - do you expect admins to need to modify that by hand? (Bear in mind that in the case of a major issue, someone can create their own role, or login as a superuser). I'm not objecting, it just seems a little off.

I think you do want a code_user role if you are going to have code_admin.
While other apps might not have one, it does seems like it would be a better user-experience to add it.

@spacedragon
Copy link
Contributor Author

added a code_user role

@tvernum
Copy link
Contributor

tvernum commented Jan 16, 2019

Thanks @spacedragon.
I'm happy with the change - we just need to update ReservedRolesStoreTests to have tests for these 2 new roles that mimic the existing tests. It should be self-explanatory, but ping me if you need more info.

@spacedragon
Copy link
Contributor Author

@tvernum I added those unit tests, but It seems the ci jobs are failed. I don't know if these failures are related to my changes.

@tvernum
Copy link
Contributor

tvernum commented Jan 16, 2019

Those failures don't look related.

@elasticmachine run gradle build tests 1 ; run gradle build tests 2

@tvernum
Copy link
Contributor

tvernum commented Jan 16, 2019

@spacedragon I fixed a couple of tests, we'll see how CI goes.

@tvernum

This comment has been minimized.

@tvernum

This comment has been minimized.

@spacedragon
Copy link
Contributor Author

@tvernum Thanks a lot for your help, could I merge this pr now?

@tvernum
Copy link
Contributor

tvernum commented Jan 24, 2019

@spacedragon We need to get the build green before we can merge. I haven't been checking the most recent failures because Elasticsearch CI has had a bunch of internal problems, but they should be resolved now.
If this build fails we'll need to look at why that's happening.

@spacedragon
Copy link
Contributor Author

It's all green now.

@tvernum
Copy link
Contributor

tvernum commented Jan 24, 2019

@spacedragon Feel free to merge this.

@spacedragon spacedragon merged commit 20533c5 into elastic:master Jan 24, 2019
@spacedragon spacedragon deleted the code_system branch January 24, 2019 12:12
@tvernum
Copy link
Contributor

tvernum commented Jan 24, 2019

@spacedragon I've labelled this on the assumption that you will want to backport this to 6.7
Let me know if you need assistance with that.

@spacedragon
Copy link
Contributor Author

@tvernum Thanks.
@zfy0701 What's the requirement of elasticsearch for our first code release? I think it's 7.0.0, right?

jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Jan 24, 2019
* elastic/master:
  Optimize warning header de-duplication (elastic#37725)
  Bubble exceptions up in ClusterApplierService (elastic#37729)
  SQL: Improve handling of invalid args for PERCENTILE/PERCENTILE_RANK (elastic#37803)
  Remove unused ThreadBarrier class (elastic#37666)
  Add built-in user and role for code plugin (elastic#37030)
  Consolidate testclusters tests into a single project (elastic#37362)
  Fix docs for MappingUpdatedAction
  SQL: Introduce SQL DATE data type (elastic#37693)
  disabling bwc test while backporting elastic#37639
  Mute ClusterDisruptionIT testAckedIndexing
  Set acking timeout to 0 on dynamic mapping update (elastic#31140)
  Remove index audit output type (elastic#37707)
  Mute FollowerFailOverIT testReadRequestsReturnsLatestMappingVersion
  [ML] Increase close job timeout and lower the max number (elastic#37770)
  Remove Custom Listeners from SnapshotsService (elastic#37629)
  Use m_m_nodes from Zen1 master for Zen2 bootstrap (elastic#37701)
  Fix index filtering in follow info api. (elastic#37752)
  Use project dependency instead of substitutions for distributions (elastic#37730)
  Update authenticate to allow unknown fields (elastic#37713)
  Deprecate HLRC EmptyResponse used by security (elastic#37540)
@tvernum tvernum removed the v6.7.0 label Feb 6, 2019
@tvernum
Copy link
Contributor

tvernum commented Feb 6, 2019

I dropped the 6.7.0 label since it didn't get backported. Hopefully you only wanted this on 7.0

@jimczi jimczi added >non-issue and removed :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC labels Feb 11, 2019
@legrego
Copy link
Member

legrego commented Apr 16, 2019

I would like to partially revert this PR. With the introduction of Kibana Feature Controls (and Code's support for it), the reserved code_admin and code_user roles are no longer necessary.
Is is possible to remove reserve roles in a minor release?

As far as I can tell, those roles aren't doing anything for customers today, as the corresponding code app isn't available yet. So if we remove this role, we shouldn't be revoking any access that users are relying on today.

@elastic/codesearch do you agree, or am I overlooking anything here?

@zfy0701
Copy link

zfy0701 commented Apr 16, 2019

I would like to partially revert this PR. With the introduction of Kibana Feature Controls (and Code's support for it), the reserved code_admin and code_user roles are no longer necessary.
Is is possible to remove reserve roles in a minor release?

As far as I can tell, those roles aren't doing anything for customers today, as the corresponding code app isn't available yet. So if we remove this role, we shouldn't be revoking any access that users are relying on today.

@elastic/codesearch do you agree, or am I overlooking anything here?

agree, I don't think we need them

@colings86 colings86 added :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC and removed :Code labels Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants