-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Security/AuthorizationRoles, Privileges, DLS/FLS, RBAC/ABACRoles, Privileges, DLS/FLS, RBAC/ABAC
Description
Describe the feature:
I'm using ES Version 7.3.1. When I try to write transient cluster settings - in my custom plugin - it throws an exception that the [_system] user does not have the [cluster:admin/settings/update] right.
At the moment I'm patching the Java class org.elasticsearch.xpack.core.security.authz.privilege.SystemPrivilege.class found in the x-pack-core-7.3.1.jar by adding "cluster:admin/settings/*", to the ALLOWED_ACTIONS list. Doing this with every ES release is rather annoying. It would be great if you could add the missing right like you already have done with issue #33119 . Thanks!
Example code to write transient settings:
ClusterUpdateSettingsRequest settingsUpdateRequest = new ClusterUpdateSettingsRequest();
settingsUpdateRequest.transientSettings(s);
ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = clientProvider.get().admin().cluster().updateSettings(settingsUpdateRequest).get();
if (clusterUpdateSettingsResponse.isAcknowledged()) {
LOG.debug("Transient cluster setting '" + structuredSettingName + "' set to '" + value + "'");
} else {
LOG.debug("Failed to set the transient setting '" + structuredSettingName + "' to '" + value + "'");
}
It will throw the following exception:
[2019-08-29T13:57:47,790][ERROR][d.v.b.e.p.BpcConnections ] [node-of-1][es-bpc-plugin] Failed to write the transient cluster setting 'connections'.
java.util.concurrent.ExecutionException: ElasticsearchSecurityException[action [cluster:admin/settings/update] is unauthorized for user [_system]]
at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.getValue(BaseFuture.java:266) ~[elasticsearch-7.3.1.jar:7.3.1]
at org.elasticsearch.common.util.concurrent.BaseFuture$Sync.get(BaseFuture.java:253) ~[elasticsearch-7.3.1.jar:7.3.1]
at org.elasticsearch.common.util.concurrent.BaseFuture.get(BaseFuture.java:87) ~[elasticsearch-7.3.1.jar:7.3.1]
...
Updated/patched SystemPrivilege.java (ES 7.3.1)
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.core.security.authz.privilege;
import org.elasticsearch.index.seqno.RetentionLeaseActions;
import org.elasticsearch.index.seqno.RetentionLeaseBackgroundSyncAction;
import org.elasticsearch.index.seqno.RetentionLeaseSyncAction;
import org.elasticsearch.transport.TransportActionProxy;
import org.elasticsearch.xpack.core.security.support.Automatons;
import java.util.Collections;
import java.util.function.Predicate;
public final class SystemPrivilege extends Privilege {
public static SystemPrivilege INSTANCE = new SystemPrivilege();
private static final Predicate<String> ALLOWED_ACTIONS = Automatons.predicate(
"internal:*",
"cluster:admin/settings/*",
"indices:monitor/*", // added for monitoring
"cluster:monitor/*", // added for monitoring
"cluster:admin/bootstrap/*", // for the bootstrap service
"cluster:admin/reroute", // added for DiskThresholdDecider.DiskListener
"indices:admin/mapping/put", // needed for recovery and shrink api
"indices:admin/template/put", // needed for the TemplateUpgradeService
"indices:admin/template/delete", // needed for the TemplateUpgradeService
"indices:admin/seq_no/global_checkpoint_sync*", // needed for global checkpoint syncs
RetentionLeaseSyncAction.ACTION_NAME + "*", // needed for retention lease syncs
RetentionLeaseBackgroundSyncAction.ACTION_NAME + "*", // needed for background retention lease syncs
RetentionLeaseActions.Add.ACTION_NAME + "*", // needed for CCR to add retention leases
RetentionLeaseActions.Remove.ACTION_NAME + "*", // needed for CCR to remove retention leases
RetentionLeaseActions.Renew.ACTION_NAME + "*", // needed for CCR to renew retention leases
"indices:admin/settings/update" // needed for DiskThresholdMonitor.markIndicesReadOnly
);
private static final Predicate<String> PREDICATE = (action) -> {
// Only allow a proxy action if the underlying action is allowed
if (TransportActionProxy.isProxyAction(action)) {
return ALLOWED_ACTIONS.test(TransportActionProxy.unwrapAction(action));
} else {
return ALLOWED_ACTIONS.test(action);
}
};
private SystemPrivilege() {
super(Collections.singleton("internal"));
}
@Override
public Predicate<String> predicate() {
return PREDICATE;
}
}
Metadata
Metadata
Assignees
Labels
:Security/AuthorizationRoles, Privileges, DLS/FLS, RBAC/ABACRoles, Privileges, DLS/FLS, RBAC/ABAC