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

Refactor cluster privileges and cluster permission #45265

Merged
merged 11 commits into from
Aug 12, 2019

Conversation

bizybot
Copy link
Contributor

@bizybot bizybot commented Aug 7, 2019

The current implementations make it difficult for
adding new privileges (example: a cluster privilege which is
more than cluster action-based and not exposed to the security
administrator). On the high level, we would like our cluster privilege
either:

  • a named cluster privilege
    This corresponds to cluster field from the role descriptor
  • or a configurable cluster privilege
    This corresponds to the global field from the role-descriptor and
    allows a security administrator to configure them.

Some of the responsibilities like the merging of action based cluster privileges
are now pushed at cluster permission level. How to implement the predicate
(using Automaton) is being now enforced by cluster permission.

ClusterPermission helps in enforcing the cluster level access either by
performing checks against cluster action and optionally against a request.
It is a collection of one or more permission checks where if any of the checks
allow access then the permission allows access to a cluster action.

Implementations of cluster privilege must be able to provide information
regarding the predicates to the cluster permission so that can be enforced.
This is enforced by making implementations of cluster privilege aware of
cluster permission builder and provide a way to specify how the permission is
to be built for a given privilege.

This commit renames ConditionalClusterPrivilege to ConfigurableClusterPrivilege.
ConfigurableClusterPrivilege is a renderable cluster privilege exposed
as a global field in role descriptor.

Other than this there is a requirement where we would want to know if a cluster
permission is implied by another cluster-permission (has-privileges).
This is helpful in addressing queries related to privileges for a user.
This is not just simply checking of cluster permissions since we do not
have access to runtime information (like request object).
This refactoring does not try to address those scenarios.

Relates #44048

bizybot and others added 9 commits July 23, 2019 20:46
…44729)

This commit renames `ConditionalClusterPrivilege` to `ConfigurableClusterPrivilege`.
`ConfigurableClusterPrivilege` is a renderable cluster privilege exposed
as a `global` field in role descriptor.
…4842)

This commit extracts the code related to converting name to `ClusterPrivilege`
from `ClusterPrivilege` class into `ClusterPrivilegeResolver`
 and updates the references.

Relates #44048
The current implementations make it difficult for
adding new privileges (example: a cluster privilege which is
more than cluster action-based and not exposed to the security
administrator). On the high level, we would like our cluster privilege
either:
- a named cluster privilege
  This corresponds to `cluster` field from the role descriptor
- or a configurable cluster privilege
  This corresponds to the `global` field from the role-descriptor and
allows a security administrator to configure them.

Some of the responsibilities like the merging of action based cluster privileges
are now pushed at cluster permission level. How to implement the predicate
(using Automaton) is being now enforced by cluster permission.

`ClusterPermission` helps in enforcing the cluster level access either by
performing checks against cluster action and optionally against a request.
It is a collection of one or more permission checks where if any of the checks
allow access then the permission allows access to a cluster action.

Implementations of cluster privilege must be able to provide information
regarding the predicates to the cluster permission so that can be enforced.
This is enforced by making implementations of cluster privilege aware of
cluster permission builder and provide a way to specify how the permission is
to be built for a given privilege.

Other than this there is a requirement where we would want to know if a cluster
permission is implied by another cluster-permission (`has-privileges`).
This is helpful in addressing queries related to privileges for a user.
This is not just simply checking of cluster permissions since we do not
have access to runtime information (like request object).
This refactoring does not try to address those scenarios.

Relates #44048
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security

@bizybot
Copy link
Contributor Author

bizybot commented Aug 7, 2019

This PR is a combination of all the PRs that have been reviewed in the following:
#44729
#44842
#44932

@bizybot
Copy link
Contributor Author

bizybot commented Aug 7, 2019

@elasticmachine run elasticsearch-ci/packaging-sample

@albertzaharovits
Copy link
Contributor

Shouldn't #45267 be batched on this PR as well?
I had the impression that there were other loose ends, no? I will review, just asking.

@bizybot
Copy link
Contributor Author

bizybot commented Aug 8, 2019

Shouldn't #45267 be batched on this PR as well?
I had the impression that there were other loose ends, no? I will review, just asking.

Hi @albertzaharovits,
I raised #45267 as a proposal and if we agree that it makes sense to do that, then I will hold this one and once that is approved I will update this to include it.

@bizybot
Copy link
Contributor Author

bizybot commented Aug 8, 2019

Hi @albertzaharovits and @tvernum, As discussed I have closed the other PR so this can be merged so I can raise next PRs related to manage own API key privilege. Please review when you get some time. Thank you.

Copy link
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

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

LGTM, save for the suggestion in RestGetUserPrivilegesAction.

if (permissionCheck instanceof AutomatonPermissionCheck) {
return Operations.subsetOf(((AutomatonPermissionCheck) permissionCheck).automaton, this.automaton);
}
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I worry we might lose track of the has_privileges scenarios that do not work because of this, e.g. all does not imply application privileges.
After this is merged to master, can you please raise an issue about it, so we don't have to fake surprise when that happens? 😛 (It will require some work to clearly scope out the scenarios that don't work).

* @param builder {@link ClusterPermission.Builder}
* @return an instance of {@link ClusterPermission.Builder}
*/
ClusterPermission.Builder buildPermission(ClusterPermission.Builder builder);
Copy link
Contributor

Choose a reason for hiding this comment

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

We had a bunch of discussions about "implies", "privileges" and "permissions". Given this interface, it is impossible for a PermissionCheck to say if a ClusterPrivilege is implied or not.
I suggest we enrich this interface and have an impliedBy(ClusterPermission clusterPermission) or impliedBy(PermissionCheck check) method.

This is a suggestion for our future selves, not to be treated in this PR, ofc!

@bizybot
Copy link
Contributor Author

bizybot commented Aug 9, 2019

@elasticmachine update branch

@bizybot
Copy link
Contributor Author

bizybot commented Aug 9, 2019

Could not download commons-io.jar
@elasticmachine run elasticsearch-ci/bwc
@elasticmachine run elasticsearch-ci/default-distro

@bizybot bizybot merged commit b44c028 into master Aug 12, 2019
@bizybot bizybot deleted the refactor-cluster-privileges branch August 12, 2019 03:27
bizybot added a commit to bizybot/elasticsearch that referenced this pull request Aug 12, 2019
The current implementations make it difficult for
adding new privileges (example: a cluster privilege which is
more than cluster action-based and not exposed to the security
administrator). On the high level, we would like our cluster privilege
either:
- a named cluster privilege
  This corresponds to `cluster` field from the role descriptor
- or a configurable cluster privilege
  This corresponds to the `global` field from the role-descriptor and
allows a security administrator to configure them.

Some of the responsibilities like the merging of action based cluster privileges
are now pushed at cluster permission level. How to implement the predicate
(using Automaton) is being now enforced by cluster permission.

`ClusterPermission` helps in enforcing the cluster level access either by
performing checks against cluster action and optionally against a request.
It is a collection of one or more permission checks where if any of the checks
allow access then the permission allows access to a cluster action.

Implementations of cluster privilege must be able to provide information
regarding the predicates to the cluster permission so that can be enforced.
This is enforced by making implementations of cluster privilege aware of
cluster permission builder and provide a way to specify how the permission is
to be built for a given privilege.

This commit renames `ConditionalClusterPrivilege` to `ConfigurableClusterPrivilege`.
`ConfigurableClusterPrivilege` is a renderable cluster privilege exposed
as a `global` field in role descriptor.

Other than this there is a requirement where we would want to know if a cluster
permission is implied by another cluster-permission (`has-privileges`).
This is helpful in addressing queries related to privileges for a user.
This is not just simply checking of cluster permissions since we do not
have access to runtime information (like request object).
This refactoring does not try to address those scenarios.

Relates elastic#44048
bizybot added a commit that referenced this pull request Aug 12, 2019
The current implementations make it difficult for
adding new privileges (example: a cluster privilege which is
more than cluster action-based and not exposed to the security
administrator). On the high level, we would like our cluster privilege
either:
- a named cluster privilege
  This corresponds to `cluster` field from the role descriptor
- or a configurable cluster privilege
  This corresponds to the `global` field from the role-descriptor and
allows a security administrator to configure them.

Some of the responsibilities like the merging of action based cluster privileges
are now pushed at cluster permission level. How to implement the predicate
(using Automaton) is being now enforced by cluster permission.

`ClusterPermission` helps in enforcing the cluster level access either by
performing checks against cluster action and optionally against a request.
It is a collection of one or more permission checks where if any of the checks
allow access then the permission allows access to a cluster action.

Implementations of cluster privilege must be able to provide information
regarding the predicates to the cluster permission so that can be enforced.
This is enforced by making implementations of cluster privilege aware of
cluster permission builder and provide a way to specify how the permission is
to be built for a given privilege.

This commit renames `ConditionalClusterPrivilege` to `ConfigurableClusterPrivilege`.
`ConfigurableClusterPrivilege` is a renderable cluster privilege exposed
as a `global` field in role descriptor.

Other than this there is a requirement where we would want to know if a cluster
permission is implied by another cluster-permission (`has-privileges`).
This is helpful in addressing queries related to privileges for a user.
This is not just simply checking of cluster permissions since we do not
have access to runtime information (like request object).
This refactoring does not try to address those scenarios.

Relates #44048
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants