-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
[Failure Store] Has Privileges API #125329
[Failure Store] Has Privileges API #125329
Conversation
if (resourcePrivilegesMapBuilder != null) { | ||
resourcePrivilegesMapBuilder.addResourcePrivilege(forIndexPattern, privilege, Boolean.TRUE); | ||
} | ||
} else { | ||
} else if (checkWithFailuresSelector | ||
&& allowedPrivilegesAutomatonForFailuresSelector != null |
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.
one optimization to consider: we could wrap getIndexPrivilegesAutomaton
calls into CachedSupplier
and make allowedPrivilegesAutomatonForFailuresSelector
and allowedPrivilegesAutomatonForDataSelector
be computed lazily when checkWithDataSelector
or checkWithFailuresSelector
is true - respectively
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.
I was thinking about this too but CachedSupplier
involves a synchronized
block and might be a little too heavy for the context here (since we don't need synchronization here, I don't think) -- at least I can't immediately say if it would provide an actual gain or not. My thinking here is:
- Most calls will be checking for data selectors privileges (there are more of them, and it's the "normal" workflow to access regular data)
- This means we'll need the data selectors automata most of the time, which is why I added short-circuiting failures-only selector computation via
containsPrivilegesForFailuresSelector
. We could do the same for data selectors but that's another pass over the privileges with another set of Map look-ups, or something slightly more complicated
Let me know if you have a stronger intuition here. I'd love to benchmark this and get some real performance numbers but would not want to block on 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.
Good point - we don't want synchronization here. FWIW We could implement a non-blocking version of cached supplier, but I don't feel this is something we should block on. My intuition is the same, we would be mostly checking data selectors and the optimization you already have could be sufficient.
Pinging @elastic/es-security (Team:Security) |
...aRestTest/java/org/elasticsearch/xpack/security/failurestore/FailureStoreSecurityRestIT.java
Outdated
Show resolved
Hide resolved
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 👍
💔 Backport failed
You can use sqren/backport to manually backport by running |
This PR adds support for checking access to the failure store via the Has Privileges API.
To check access for a data stream
logs
, a request must query for a concrete named privilege,read_failure_store
ormanage_failure_store
, e.g., a request to the HasPrivileges API by a user withread_failure_store
overlogs
:Returns:
Note that
<1>
and<2>
are bothfalse
sinceread
is not covered byread_failure_store
and neither are any raw actions likeindices:data/read/*
since these implicitly correspond to data access.Selectors are not allowed in the index patterns of HasPrivileges requests to avoid ambiguities such as checking
read
onlogs::failures
as well as the ambiguity of index patterns that are regular expressions.