-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Allow users to get status of own async search tasks #106638
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
Conversation
This commit moves code from AsyncTaskIndexService and DeleteAsyncResultsService into a new AsyncSearchSecurity so that all security code is centralised.,
This changs RBAC engine so users with access to submit async searches also have permission to retrive async search status. It relies on the fact that async search will check that the user owns the async search task
Manual testing results, comparing code on
|
…enforced while search is running
Pinging @elastic/es-security (Team:Security) |
I will look into reviewing this tomorrow morning. |
Hi @tvernum, I've created a changelog YAML for you. |
@elasticmachine update branch |
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, very neat! Thank you @tvernum! 👍
Also thank you @quux00 for the testing from #106638 (comment) ! This was very useful to me!
Re the 403 vs 404 issue. Previously, the 403 was returned because /async-search/status
was simply not allowed for users without the monitor
cluster privilege, for any async search id.
But the premise of this PR is that we want that to succeed (200), if the same user submitted the async search that's querying the status of. For the other, non-owned async searches, between 403 and 404, 404 is clearly favorable. Some reasons are: consistency with the async-search
(result) endpoint and consistency with the /async-search/status
endpoint, when Security is disabled.
@quux00 Re the separate bug that you've identified, when the user only has the monitor
cluster privilege and is issuing a /async-search/status
request with the keep_alive
parameter, I believe a quick fix would look like:
diff --git a/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/TransportGetAsyncStatusAction.java b/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/TransportGetAsyncStatusAction.java
index cc5cd797f3f..cc27e82a693 100644
--- a/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/TransportGetAsyncStatusAction.java
+++ b/x-pack/plugin/async-search/src/main/java/org/elasticsearch/xpack/search/TransportGetAsyncStatusAction.java
@@ -35,6 +35,7 @@ import java.util.Objects;
import static org.elasticsearch.core.Strings.format;
import static org.elasticsearch.xpack.core.ClientHelper.ASYNC_SEARCH_ORIGIN;
+import static org.elasticsearch.xpack.core.async.AsyncTaskIndexService.getTask;
public class TransportGetAsyncStatusAction extends HandledTransportAction<GetAsyncStatusRequest, AsyncStatusResponse> {
private final TransportService transportService;
@@ -76,7 +77,7 @@ public class TransportGetAsyncStatusAction extends HandledTransportAction<GetAsy
if (request.getKeepAlive() != null && request.getKeepAlive().getMillis() > 0) {
long expirationTime = System.currentTimeMillis() + request.getKeepAlive().getMillis();
store.updateExpirationTime(searchId.getDocId(), expirationTime, ActionListener.wrap(p -> {
- AsyncSearchTask asyncSearchTask = store.getTaskAndCheckAuthentication(taskManager, searchId, AsyncSearchTask.class);
+ AsyncSearchTask asyncSearchTask = getTask(taskManager, searchId, AsyncSearchTask.class);
if (asyncSearchTask != null) {
asyncSearchTask.setExpirationTime(expirationTime);
}
Would you be available to handle this in a separate fix PR?
Thanks @albertzaharovits for the review and for the proposed fix to the existing bug. I will open a new PR with the patch you provided. |
I'd like to merge this, but two of the Hdfs tests under fips conditions are failing. I'm able to reproduce one locally, but it also fails on main so seems unrelated to this PR.
Stack trace of failure:
Issue filed here: #106845 |
this should be fixed on main (we ignore fips for hdfs). rebasing should fix the hdfs issue for you |
@elasticmachine update branch |
This consists of 3 changes:
AsyncSearchSecurity
TransportGetAsyncStatusAction
to check for ownership if the user does not have explicit access to theGetAsyncStatusAction
(if they have such access it means that they can get the status of all async searches)GetAsyncStatusAction
but does have permission to submit async searches, then let them run the action, relying on point 2 above.