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

Introduce "ConditionalClusterPrivilege" #32073

Merged

Conversation

tvernum
Copy link
Contributor

@tvernum tvernum commented Jul 16, 2018

A conditional cluster privilege is like the existing cluster
privilege, except that it has a Predicate over the request as
well as over the action name.
It is the "role descriptor" level representation for the newly
introduced "ConditionalClusterPermission"

This change adds the ConditionalClusterPrivilege interface, and
allows them to be attached to RoleDescriptors, but does not provide
any JSON/XContent support. This means that they cannot be used in the
Roles API, nor are they stored in the security index, but they can be
defined by custom Roles Providers and will be consulted as part of
authorization decisions on Roles.

A conditional cluster privilege is like the existing cluster
privilege, except that it has a Predicate over the request as
well as over the action name.
It is the "role descriptor" level representation for the newly
introduced "ConditionalClusterPermission"

This change adds the ConditionalClusterPrivilege interface, and
allows them to be attached to RoleDescriptors, but does not provide
any JSON/XContent support. This means that they cannot be used in the
Roles API, nor are they stored in the security index, but they can be
defined by custom Roles Providers and will be consulted as part of
authorization decisions on Roles.
@tvernum tvernum added review :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC labels Jul 16, 2018
@tvernum tvernum requested a review from jaymode July 16, 2018 07:37
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security

public static void writeArray(StreamOutput out, ConditionalClusterPrivilege[] privileges) throws IOException {
out.writeArray((out1, value) -> out1.writeNamedWriteable(value), privileges);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This class is small and seems a bit redundant right now, but it will handle the XContent parsing/building when we add that.

Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

LGTM

/**
* The request-level privilege (as a {@link Predicate}) that is required by this conditional privilege.
*/
Predicate<TransportRequest> getRequestPredicate();
Copy link
Member

Choose a reason for hiding this comment

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

We currently have special handling for same user privileges. I wonder if it is worth a refactor to change this to a BiPredicate, which would cover that case as well. I'm tossing this out there as an idea and we can always defer this to later on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a good idea - I'll see about adding it in a followup.

@tvernum tvernum merged commit df1ca1f into elastic:security-app-privs Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants