Skip to content

Commit

Permalink
Updated conditions for unstashing the context when indexing and delet…
Browse files Browse the repository at this point in the history
…ing the workflow

Signed-off-by: Stevan Buzejic <[email protected]>
  • Loading branch information
stevanbz committed Apr 19, 2023
1 parent e418851 commit b303435
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ class TransportDeleteWorkflowAction @Inject constructor(

val deleteResponse = deleteWorkflow(workflow)
if (deleteDelegateMonitors == true) {
if (user == null) {
deleteMonitors(delegateMonitorIds, RefreshPolicy.IMMEDIATE)
} else {
if (user != null && filterByEnabled) {
// Un-stash the context
withClosableContext(
InjectorContextElement(
Expand All @@ -167,6 +165,8 @@ class TransportDeleteWorkflowAction @Inject constructor(
) {
deleteMonitors(delegateMonitorIds, RefreshPolicy.IMMEDIATE)
}
} else {
deleteMonitors(delegateMonitorIds, RefreshPolicy.IMMEDIATE)
}
}
actionListener.onResponse(DeleteWorkflowResponse(deleteResponse.id, deleteResponse.version))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ class TransportIndexWorkflowAction @Inject constructor(
val searchSource = SearchSourceBuilder().query(query)
val searchRequest = SearchRequest(SCHEDULED_JOBS_INDEX).source(searchSource)

if (user != null && !isAdmin(user) && filterByEnabled) {
if (user != null && filterByEnabled) {
addFilter(user, searchRequest.source(), "monitor.user.backend_roles.keyword")
}

Expand Down Expand Up @@ -647,9 +647,7 @@ class TransportIndexWorkflowAction @Inject constructor(
val indicesSearchRequest = SearchRequest().indices(*indices.toTypedArray())
.source(SearchSourceBuilder.searchSource().size(1).query(QueryBuilders.matchAllQuery()))

if (user == null) {
checkIndicesAccess(client, indicesSearchRequest, indices, actionListener)
} else {
if (user != null && filterByEnabled) {
// Unstash the context and check if user with specified roles has indices access
withClosableContext(
InjectorContextElement(
Expand All @@ -662,6 +660,8 @@ class TransportIndexWorkflowAction @Inject constructor(
) {
checkIndicesAccess(client, indicesSearchRequest, indices, actionListener)
}
} else {
checkIndicesAccess(client, indicesSearchRequest, indices, actionListener)
}
}

Expand Down

0 comments on commit b303435

Please sign in to comment.