Skip to content
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

Only run DlsFlsValveImpl.invoke on indices requests #4937

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.opensearch.action.bulk.BulkItemRequest;
import org.opensearch.action.bulk.BulkShardRequest;
import org.opensearch.action.search.SearchRequest;
import org.opensearch.action.update.UpdateAction;
import org.opensearch.action.update.UpdateRequest;
import org.opensearch.client.Client;
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
Expand Down Expand Up @@ -264,7 +265,7 @@ public boolean invoke(PrivilegesEvaluationContext context, final ActionListener<
}
}

if (request instanceof UpdateRequest) {
if (UpdateAction.NAME.equals(context.getAction())) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change wouldn't be needed if opensearch-project/index-management#1311 is merged

listener.onFailure(new OpenSearchSecurityException("Update is not supported when FLS or DLS or Fieldmasking is activated"));
return false;
}
Expand Down Expand Up @@ -679,7 +680,7 @@ static Mode get(Settings settings) {
public void updateConfiguration(SecurityDynamicConfiguration<RoleV7> rolesConfiguration) {
try {
if (rolesConfiguration != null) {
DlsFlsProcessedConfig oldConfig = this.dlsFlsProcessedConfig.getAndSet(
this.dlsFlsProcessedConfig.set(
new DlsFlsProcessedConfig(
DynamicConfigFactory.addStatics(rolesConfiguration.clone()),
clusterService.state().metadata().getIndicesLookup(),
Expand All @@ -688,10 +689,6 @@ public void updateConfiguration(SecurityDynamicConfiguration<RoleV7> rolesConfig
fieldMaskingConfig
)
);

if (oldConfig != null) {
oldConfig.shutdown();
}
}
} catch (Exception e) {
log.error("Error while updating DLS/FLS configuration with {}", rolesConfiguration, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ protected void updateClusterStateMetadata(Metadata metadata) {
long duration = System.currentTimeMillis() - start;

log.debug("Updating DlsFlsProcessedConfig took {} ms", duration);
this.metadataVersionEffective = metadata.version();
}

@Override
Expand Down
Loading