Skip to content

Commit

Permalink
Addressed additional PR Comments
Browse files Browse the repository at this point in the history
Signed-off-by: Owais <[email protected]>
  • Loading branch information
owaiskazi19 committed Aug 23, 2024
1 parent e5a4c74 commit 7f3dbdc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public class CreateWorkflowTransportAction extends HandledTransportAction<Workfl
private final FlowFrameworkSettings flowFrameworkSettings;
private final PluginsService pluginsService;
private volatile Boolean filterByEnabled;
private final Settings settings;
private final ClusterService clusterService;
private final NamedXContentRegistry xContentRegistry;

Expand Down Expand Up @@ -110,7 +109,6 @@ public CreateWorkflowTransportAction(
this.clusterService = clusterService;
clusterService.getClusterSettings().addSettingsUpdateConsumer(FILTER_BY_BACKEND_ROLES, it -> filterByEnabled = it);
this.xContentRegistry = xContentRegistry;
this.settings = settings;
}

@Override
Expand Down Expand Up @@ -141,7 +139,7 @@ private void resolveUserAndExecute(
try {
// Check if user has backend roles
// When filter by is enabled, block users creating/updating workflows who do not have backend roles.
if (filterByEnabled) {
if (filterByEnabled == Boolean.TRUE) {
try {
checkFilterByBackendRoles(requestedUser);
} catch (FlowFrameworkException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void validateRole(
// Security is enabled, filter is enabled and user isn't admin
try {
ParseUtils.addUserBackendRolesFilter(user, request.source());
logger.debug("Filtering result by " + user.getBackendRoles());
logger.debug("Filtering result by {}", user.getBackendRoles());
client.search(request, ActionListener.runBefore(listener, context::restore));
} catch (Exception e) {
listener.onFailure(e);

Check warning on line 94 in src/main/java/org/opensearch/flowframework/transport/handler/SearchHandler.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/flowframework/transport/handler/SearchHandler.java#L93-L94

Added lines #L93 - L94 were not covered by tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.opensearch.commons.ConfigConstants;
import org.opensearch.commons.authuser.User;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.core.common.bytes.BytesReference;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.core.xcontent.NamedXContentRegistry;
Expand Down Expand Up @@ -292,14 +293,14 @@ public static void resolveUserAndExecute(
User requestedUser,
String workflowId,
Boolean filterByEnabled,
ActionListener listener,
ActionListener<? extends ActionResponse> listener,
Runnable function,
Client client,
ClusterService clusterService,
NamedXContentRegistry xContentRegistry
) {
try {
if (requestedUser == null || !filterByEnabled) {
if (requestedUser == null || filterByEnabled == Boolean.FALSE) {
// requestedUser == null means security is disabled or user is superadmin. In this case we don't need to
// check if request user have access to the workflow or not.
// !filterByEnabled means security is enabled and filterByEnabled is disabled
Expand Down

0 comments on commit 7f3dbdc

Please sign in to comment.