-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
Introduce "ConditionalClusterPrivilege" #32073
Conversation
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.
Pinging @elastic/es-security |
public static void writeArray(StreamOutput out, ConditionalClusterPrivilege[] privileges) throws IOException { | ||
out.writeArray((out1, value) -> out1.writeNamedWriteable(value), privileges); | ||
} | ||
|
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.
This class is small and seems a bit redundant right now, but it will handle the XContent parsing/building when we add that.
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.
LGTM
/** | ||
* The request-level privilege (as a {@link Predicate}) that is required by this conditional privilege. | ||
*/ | ||
Predicate<TransportRequest> getRequestPredicate(); |
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.
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
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.
This is a good idea - I'll see about adding it in a followup.
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.