Merge pull request elastic/elasticsearch#3069 from rjernst/deguice18
Consolidate settings for enabling xpack features Original commit: elastic/x-pack-elasticsearch@bdc505dc6b
This commit is contained in:
commit
20041446f3
|
@ -7,15 +7,14 @@ package org.elasticsearch.xpack.graph;
|
|||
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.common.component.LifecycleComponent;
|
||||
import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.inject.util.Providers;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugins.ActionPlugin;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.rest.RestHandler;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.graph.action.GraphExploreAction;
|
||||
import org.elasticsearch.xpack.graph.action.TransportGraphExploreAction;
|
||||
import org.elasticsearch.xpack.graph.rest.action.RestGraphAction;
|
||||
|
@ -30,17 +29,11 @@ import static java.util.Collections.singletonList;
|
|||
public class Graph extends Plugin implements ActionPlugin {
|
||||
|
||||
public static final String NAME = "graph";
|
||||
private final boolean transportClientMode;
|
||||
protected final boolean enabled;
|
||||
|
||||
|
||||
public Graph(Settings settings) {
|
||||
this.transportClientMode = XPackPlugin.transportClientMode(settings);
|
||||
enabled = enabled(settings);
|
||||
}
|
||||
|
||||
public static boolean enabled(Settings settings) {
|
||||
return XPackPlugin.featureEnabled(settings, NAME, true);
|
||||
this.enabled = XPackSettings.GRAPH_ENABLED.get(settings);
|
||||
}
|
||||
|
||||
public Collection<Module> createGuiceModules() {
|
||||
|
@ -64,10 +57,4 @@ public class Graph extends Plugin implements ActionPlugin {
|
|||
}
|
||||
return singletonList(RestGraphAction.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Setting<?>> getSettings() {
|
||||
return Collections.singletonList(Setting.boolSetting(XPackPlugin.featureEnabledSetting(NAME), true, Setting.Property.NodeScope));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.xpack.XPackFeatureSet;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -24,13 +26,13 @@ public class GraphFeatureSet implements XPackFeatureSet {
|
|||
|
||||
@Inject
|
||||
public GraphFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState) {
|
||||
this.enabled = Graph.enabled(settings);
|
||||
this.enabled = XPackSettings.GRAPH_ENABLED.get(settings);
|
||||
this.licenseState = licenseState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return Graph.NAME;
|
||||
return XPackPlugin.GRAPH;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,7 +62,7 @@ public class GraphFeatureSet implements XPackFeatureSet {
|
|||
}
|
||||
|
||||
public Usage(boolean available, boolean enabled) {
|
||||
super(Graph.NAME, available, enabled);
|
||||
super(XPackPlugin.GRAPH, available, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.elasticsearch.search.aggregations.bucket.terms.support.IncludeExclude
|
|||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.graph.Graph;
|
||||
import org.elasticsearch.xpack.graph.action.Connection.ConnectionId;
|
||||
import org.elasticsearch.xpack.graph.action.GraphExploreRequest.TermBoost;
|
||||
|
@ -89,7 +90,7 @@ public class TransportGraphExploreAction extends HandledTransportAction<GraphExp
|
|||
if (licenseState.isGraphAllowed()) {
|
||||
new AsyncGraphAction(request, listener).start();
|
||||
} else {
|
||||
listener.onFailure(LicenseUtils.newComplianceException(Graph.NAME));
|
||||
listener.onFailure(LicenseUtils.newComplianceException(XPackPlugin.GRAPH));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,13 +7,12 @@ package org.elasticsearch.xpack.graph.test;
|
|||
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.search.ShardSearchFailure;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.Settings.Builder;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.query.ScriptQueryBuilder;
|
||||
import org.elasticsearch.xpack.monitoring.Monitoring;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.plugins.ScriptPlugin;
|
||||
import org.elasticsearch.script.AbstractSearchScript;
|
||||
|
@ -21,9 +20,7 @@ import org.elasticsearch.script.ExecutableScript;
|
|||
import org.elasticsearch.script.NativeScriptFactory;
|
||||
import org.elasticsearch.script.Script;
|
||||
import org.elasticsearch.script.ScriptService.ScriptType;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.graph.action.GraphExploreAction;
|
||||
import org.elasticsearch.xpack.graph.action.GraphExploreRequest;
|
||||
|
@ -128,9 +125,9 @@ public class GraphTests extends ESSingleNodeTestCase {
|
|||
public Settings nodeSettings() {
|
||||
// Disable security otherwise authentication failures happen creating indices.
|
||||
Builder newSettings = Settings.builder();
|
||||
newSettings.put(XPackPlugin.featureEnabledSetting(Security.NAME), false);
|
||||
newSettings.put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false);
|
||||
newSettings.put(XPackPlugin.featureEnabledSetting(Watcher.NAME), false);
|
||||
newSettings.put(XPackSettings.SECURITY_ENABLED.getKey(), false);
|
||||
newSettings.put(XPackSettings.MONITORING_ENABLED.getKey(), false);
|
||||
newSettings.put(XPackSettings.WATCHER_ENABLED.getKey(), false);
|
||||
return newSettings.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,33 +5,30 @@
|
|||
*/
|
||||
package org.elasticsearch.license;
|
||||
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.ClusterStateUpdateTask;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.monitoring.Monitoring;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.graph.Graph;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.ClusterStateUpdateTask;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
|
||||
public abstract class AbstractLicensesIntegrationTestCase extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.NAME), false)
|
||||
.put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false)
|
||||
.put(XPackPlugin.featureEnabledSetting(Watcher.NAME), false)
|
||||
.put(XPackPlugin.featureEnabledSetting(Graph.NAME), false)
|
||||
.put(XPackSettings.SECURITY_ENABLED.getKey(), false)
|
||||
.put(XPackSettings.MONITORING_ENABLED.getKey(), false)
|
||||
.put(XPackSettings.WATCHER_ENABLED.getKey(), false)
|
||||
.put(XPackSettings.GRAPH_ENABLED.getKey(), false)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,10 +18,7 @@ import org.elasticsearch.common.unit.TimeValue;
|
|||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.graph.Graph;
|
||||
import org.elasticsearch.xpack.monitoring.Monitoring;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
|
||||
import static org.elasticsearch.license.TestUtils.generateSignedLicense;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
@ -38,12 +35,11 @@ public class LicensesManagerServiceTests extends ESSingleNodeTestCase {
|
|||
|
||||
@Override
|
||||
protected Settings nodeSettings() {
|
||||
return Settings.builder().
|
||||
put(XPackPlugin.featureEnabledSetting(Security.NAME), false)
|
||||
.put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false)
|
||||
.put(XPackPlugin.featureEnabledSetting(Watcher.NAME), false)
|
||||
.put(XPackPlugin.featureEnabledSetting(Graph.NAME), false)
|
||||
.build();
|
||||
return Settings.builder()
|
||||
.put(XPackSettings.SECURITY_ENABLED.getKey(), false)
|
||||
.put(XPackSettings.MONITORING_ENABLED.getKey(), false)
|
||||
.put(XPackSettings.WATCHER_ENABLED.getKey(), false)
|
||||
.put(XPackSettings.GRAPH_ENABLED.getKey(), false).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,13 +8,11 @@ package org.elasticsearch.license;
|
|||
import org.elasticsearch.action.ActionFuture;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.xpack.monitoring.Monitoring;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -39,9 +37,9 @@ public class LicensesTransportTests extends ESSingleNodeTestCase {
|
|||
@Override
|
||||
protected Settings nodeSettings() {
|
||||
Settings.Builder newSettings = Settings.builder();
|
||||
newSettings.put(XPackPlugin.featureEnabledSetting(Security.NAME), false);
|
||||
newSettings.put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false);
|
||||
newSettings.put(XPackPlugin.featureEnabledSetting(Watcher.NAME), false);
|
||||
newSettings.put(XPackSettings.SECURITY_ENABLED.getKey(), false);
|
||||
newSettings.put(XPackSettings.MONITORING_ENABLED.getKey(), false);
|
||||
newSettings.put(XPackSettings.WATCHER_ENABLED.getKey(), false);
|
||||
newSettings.put(Node.NODE_DATA_SETTING.getKey(), true);
|
||||
return newSettings.build();
|
||||
}
|
||||
|
|
|
@ -22,21 +22,17 @@ import org.elasticsearch.common.transport.TransportAddress;
|
|||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.monitoring.Monitoring;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||
import org.elasticsearch.test.InternalTestCluster;
|
||||
import org.elasticsearch.test.NodeConfigurationSource;
|
||||
import org.elasticsearch.test.TestCluster;
|
||||
import org.elasticsearch.xpack.graph.Graph;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -50,9 +46,6 @@ import static org.hamcrest.Matchers.equalTo;
|
|||
@ClusterScope(scope = Scope.TEST, transportClientRatio = 0, numClientNodes = 1, numDataNodes = 0)
|
||||
public abstract class TribeTransportTestCase extends ESIntegTestCase {
|
||||
|
||||
private static final Collection<String> ALL_FEATURES = Arrays.asList(Security.NAME, Monitoring.NAME,
|
||||
Watcher.NAME, Graph.NAME);
|
||||
|
||||
protected List<String> enabledFeatures() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -64,9 +57,10 @@ public abstract class TribeTransportTestCase extends ESIntegTestCase {
|
|||
.put("transport.type", "local")
|
||||
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "local");
|
||||
List<String> enabledFeatures = enabledFeatures();
|
||||
for (String feature : ALL_FEATURES) {
|
||||
builder.put(XPackPlugin.featureEnabledSetting(feature), enabledFeatures.contains(feature));
|
||||
}
|
||||
builder.put(XPackSettings.SECURITY_ENABLED.getKey(), enabledFeatures.contains(XPackPlugin.SECURITY));
|
||||
builder.put(XPackSettings.MONITORING_ENABLED.getKey(), enabledFeatures.contains(XPackPlugin.MONITORING));
|
||||
builder.put(XPackSettings.WATCHER_ENABLED.getKey(), enabledFeatures.contains(XPackPlugin.WATCHER));
|
||||
builder.put(XPackSettings.GRAPH_ENABLED.getKey(), enabledFeatures.contains(XPackPlugin.GRAPH));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.elasticsearch.license.LicenseService;
|
|||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.monitoring.action.MonitoringBulkAction;
|
||||
import org.elasticsearch.xpack.monitoring.action.TransportMonitoringBulkAction;
|
||||
import org.elasticsearch.xpack.monitoring.agent.AgentService;
|
||||
|
@ -72,7 +73,7 @@ public class Monitoring implements ActionPlugin {
|
|||
this.settings = settings;
|
||||
this.env = env;
|
||||
this.licenseState = licenseState;
|
||||
this.enabled = enabled(settings);
|
||||
this.enabled = XPackSettings.MONITORING_ENABLED.get(settings);
|
||||
this.transportClientMode = XPackPlugin.transportClientMode(settings);
|
||||
this.tribeNode = XPackPlugin.isTribeNode(settings);
|
||||
}
|
||||
|
@ -139,8 +140,4 @@ public class Monitoring implements ActionPlugin {
|
|||
}
|
||||
return singletonList(RestMonitoringBulkAction.class);
|
||||
}
|
||||
|
||||
public static boolean enabled(Settings settings) {
|
||||
return MonitoringSettings.ENABLED.get(settings);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.xpack.XPackFeatureSet;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.monitoring.agent.exporter.Exporter;
|
||||
import org.elasticsearch.xpack.monitoring.agent.exporter.Exporters;
|
||||
|
||||
|
@ -31,7 +32,7 @@ public class MonitoringFeatureSet implements XPackFeatureSet {
|
|||
|
||||
@Inject
|
||||
public MonitoringFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState, @Nullable Exporters exporters) {
|
||||
this.enabled = MonitoringSettings.ENABLED.get(settings);
|
||||
this.enabled = XPackSettings.MONITORING_ENABLED.get(settings);
|
||||
this.licenseState = licenseState;
|
||||
this.exporters = exporters;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ package org.elasticsearch.xpack.monitoring;
|
|||
|
||||
import org.elasticsearch.common.Booleans;
|
||||
import org.elasticsearch.common.component.AbstractComponent;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.ClusterSettings;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -35,18 +34,6 @@ public class MonitoringSettings extends AbstractComponent {
|
|||
*/
|
||||
public static final TimeValue HISTORY_DURATION_MINIMUM = TimeValue.timeValueHours(24);
|
||||
|
||||
/**
|
||||
* Determines whether monitoring is enabled/disabled
|
||||
*/
|
||||
public static final Setting<Boolean> ENABLED =
|
||||
new Setting<>(XPackPlugin.featureEnabledSetting(Monitoring.NAME),
|
||||
|
||||
// By default, monitoring is disabled on tribe nodes
|
||||
(s) -> String.valueOf(!XPackPlugin.isTribeNode(s) && !XPackPlugin.isTribeClientNode(s)),
|
||||
|
||||
Booleans::parseBooleanExact,
|
||||
Property.NodeScope);
|
||||
|
||||
/**
|
||||
* Sampling interval between two collections (default to 10s)
|
||||
*/
|
||||
|
@ -135,8 +122,7 @@ public class MonitoringSettings extends AbstractComponent {
|
|||
CLUSTER_STATE_TIMEOUT,
|
||||
CLUSTER_STATS_TIMEOUT,
|
||||
HISTORY_DURATION,
|
||||
EXPORTERS_SETTINGS,
|
||||
ENABLED);
|
||||
EXPORTERS_SETTINGS);
|
||||
}
|
||||
|
||||
public static List<String> getSettingsFilter() {
|
||||
|
|
|
@ -19,11 +19,11 @@ import org.elasticsearch.cluster.service.ClusterService;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringSettings;
|
||||
import org.elasticsearch.xpack.monitoring.agent.collector.AbstractCollector;
|
||||
import org.elasticsearch.xpack.monitoring.agent.exporter.MonitoringDoc;
|
||||
import org.elasticsearch.xpack.security.InternalClient;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
|
||||
/**
|
||||
* Collector for the Recovery API.
|
||||
|
@ -67,7 +67,8 @@ public class IndexRecoveryCollector extends AbstractCollector {
|
|||
results.add(indexRecoveryDoc);
|
||||
}
|
||||
} catch (IndexNotFoundException e) {
|
||||
if (Security.enabled(settings) && IndexNameExpressionResolver.isAllIndices(Arrays.asList(monitoringSettings.indices()))) {
|
||||
if (XPackSettings.SECURITY_ENABLED.get(settings)
|
||||
&& IndexNameExpressionResolver.isAllIndices(Arrays.asList(monitoringSettings.indices()))) {
|
||||
logger.debug("collector [{}] - unable to collect data for missing index [{}]", name(), e.getIndex());
|
||||
} else {
|
||||
throw e;
|
||||
|
|
|
@ -21,11 +21,11 @@ import org.elasticsearch.cluster.service.ClusterService;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringSettings;
|
||||
import org.elasticsearch.xpack.monitoring.agent.collector.AbstractCollector;
|
||||
import org.elasticsearch.xpack.monitoring.agent.exporter.MonitoringDoc;
|
||||
import org.elasticsearch.xpack.security.InternalClient;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
|
||||
/**
|
||||
* Collector for indices statistics.
|
||||
|
@ -83,7 +83,8 @@ public class IndexStatsCollector extends AbstractCollector {
|
|||
results.add(indexStatsDoc);
|
||||
}
|
||||
} catch (IndexNotFoundException e) {
|
||||
if (Security.enabled(settings) && IndexNameExpressionResolver.isAllIndices(Arrays.asList(monitoringSettings.indices()))) {
|
||||
if (XPackSettings.SECURITY_ENABLED.get(settings)
|
||||
&& IndexNameExpressionResolver.isAllIndices(Arrays.asList(monitoringSettings.indices()))) {
|
||||
logger.debug("collector [{}] - unable to collect data for missing index [{}]", name(), e.getIndex());
|
||||
} else {
|
||||
throw e;
|
||||
|
|
|
@ -17,11 +17,11 @@ import org.elasticsearch.cluster.service.ClusterService;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringSettings;
|
||||
import org.elasticsearch.xpack.monitoring.agent.collector.AbstractCollector;
|
||||
import org.elasticsearch.xpack.monitoring.agent.exporter.MonitoringDoc;
|
||||
import org.elasticsearch.xpack.security.InternalClient;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
|
||||
/**
|
||||
* Collector for indices statistics.
|
||||
|
@ -66,7 +66,8 @@ public class IndicesStatsCollector extends AbstractCollector {
|
|||
|
||||
return Collections.singletonList(indicesStatsDoc);
|
||||
} catch (IndexNotFoundException e) {
|
||||
if (Security.enabled(settings) && IndexNameExpressionResolver.isAllIndices(Arrays.asList(monitoringSettings.indices()))) {
|
||||
if (XPackSettings.SECURITY_ENABLED.get(settings)
|
||||
&& IndexNameExpressionResolver.isAllIndices(Arrays.asList(monitoringSettings.indices()))) {
|
||||
logger.debug("collector [{}] - unable to collect data for missing index [{}]", name(), e.getIndex());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.plugins.PluginInfo;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.monitoring.agent.AgentService;
|
||||
import org.elasticsearch.xpack.monitoring.test.MonitoringIntegTestCase;
|
||||
|
||||
|
@ -41,7 +42,7 @@ public class MonitoringPluginTests extends MonitoringIntegTestCase {
|
|||
|
||||
public void testMonitoringEnabled() {
|
||||
internalCluster().startNode(Settings.builder()
|
||||
.put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), true)
|
||||
.put(XPackSettings.MONITORING_ENABLED.getKey(), true)
|
||||
.build());
|
||||
assertPluginIsLoaded();
|
||||
assertServiceIsBound(AgentService.class);
|
||||
|
@ -49,7 +50,7 @@ public class MonitoringPluginTests extends MonitoringIntegTestCase {
|
|||
|
||||
public void testMonitoringDisabled() {
|
||||
internalCluster().startNode(Settings.builder()
|
||||
.put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false)
|
||||
.put(XPackSettings.MONITORING_ENABLED.getKey(), false)
|
||||
.build());
|
||||
assertPluginIsLoaded();
|
||||
assertServiceIsNotBound(AgentService.class);
|
||||
|
@ -57,7 +58,7 @@ public class MonitoringPluginTests extends MonitoringIntegTestCase {
|
|||
|
||||
public void testMonitoringEnabledOnTribeNode() {
|
||||
internalCluster().startNode(Settings.builder()
|
||||
.put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), true)
|
||||
.put(XPackSettings.MONITORING_ENABLED.getKey(), true)
|
||||
.put("tribe.name", "t1")
|
||||
.build());
|
||||
assertPluginIsLoaded();
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.test.transport.AssertingLocalTransport;
|
|||
import org.elasticsearch.test.transport.MockTransportService;
|
||||
import org.elasticsearch.xpack.XPackClient;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoredSystem;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringSettings;
|
||||
import org.elasticsearch.xpack.monitoring.agent.AgentService;
|
||||
|
@ -39,7 +40,6 @@ import org.elasticsearch.xpack.security.authc.support.Hasher;
|
|||
import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
||||
import org.elasticsearch.xpack.security.authz.store.FileRolesStore;
|
||||
import org.elasticsearch.xpack.security.crypto.CryptoService;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.jboss.netty.util.internal.SystemPropertyUtil;
|
||||
import org.junit.After;
|
||||
|
@ -109,7 +109,7 @@ public abstract class MonitoringIntegTestCase extends ESIntegTestCase {
|
|||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
Settings.Builder builder = Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(XPackPlugin.featureEnabledSetting(Watcher.NAME), watcherEnabled)
|
||||
.put(XPackSettings.WATCHER_ENABLED.getKey(), watcherEnabled)
|
||||
// we do this by default in core, but for monitoring this isn't needed and only adds noise.
|
||||
.put("index.store.mock.check_index_on_close", false);
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
@ -47,6 +46,7 @@ import org.elasticsearch.rest.RestHandler;
|
|||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.watcher.ResourceWatcherService;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.extensions.XPackExtension;
|
||||
import org.elasticsearch.xpack.security.action.SecurityActionModule;
|
||||
import org.elasticsearch.xpack.security.action.filter.SecurityActionFilter;
|
||||
|
@ -137,14 +137,10 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
|
||||
private static final ESLogger logger = Loggers.getLogger(XPackPlugin.class);
|
||||
|
||||
public static final String NAME = "security";
|
||||
public static final String NAME3 = NAME + "3";
|
||||
public static final String NAME4 = NAME + "4";
|
||||
public static final String DLS_FLS_FEATURE = "security.dls_fls";
|
||||
public static final String NAME3 = XPackPlugin.SECURITY + "3";
|
||||
public static final String NAME4 = XPackPlugin.SECURITY + "4";
|
||||
public static final Setting<Optional<String>> USER_SETTING = OptionalSettings.createString(setting("user"), Property.NodeScope);
|
||||
|
||||
public static final Setting<Boolean> AUDIT_ENABLED_SETTING =
|
||||
Setting.boolSetting(featureEnabledSetting("audit"), false, Property.NodeScope);
|
||||
public static final Setting<List<String>> AUDIT_OUTPUTS_SETTING =
|
||||
Setting.listSetting(setting("audit.outputs"),
|
||||
s -> s.getAsMap().containsKey(setting("audit.outputs")) ?
|
||||
|
@ -162,7 +158,7 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
this.settings = settings;
|
||||
this.env = env;
|
||||
this.transportClientMode = XPackPlugin.transportClientMode(settings);
|
||||
this.enabled = XPackPlugin.featureEnabled(settings, NAME, true);
|
||||
this.enabled = XPackSettings.SECURITY_ENABLED.get(settings);
|
||||
if (enabled && transportClientMode == false) {
|
||||
validateAutoCreateIndex(settings);
|
||||
cryptoService = new CryptoService(settings, env);
|
||||
|
@ -176,10 +172,6 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
return cryptoService;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public Collection<Module> nodeModules() {
|
||||
List<Module> modules = new ArrayList<>();
|
||||
|
||||
|
@ -215,7 +207,7 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
// everything should have been loaded
|
||||
modules.add(b -> {
|
||||
b.bind(CryptoService.class).toInstance(cryptoService);
|
||||
if (auditingEnabled(settings)) {
|
||||
if (XPackSettings.AUDIT_ENABLED.get(settings)) {
|
||||
b.bind(AuditTrail.class).to(AuditTrailService.class); // interface used by some actions...
|
||||
}
|
||||
});
|
||||
|
@ -271,11 +263,11 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
// audit trails construction
|
||||
IndexAuditTrail indexAuditTrail = null;
|
||||
Set<AuditTrail> auditTrails = new LinkedHashSet<>();
|
||||
if (AUDIT_ENABLED_SETTING.get(settings)) {
|
||||
if (XPackSettings.AUDIT_ENABLED.get(settings)) {
|
||||
List<String> outputs = AUDIT_OUTPUTS_SETTING.get(settings);
|
||||
if (outputs.isEmpty()) {
|
||||
throw new IllegalArgumentException("Audit logging is enabled but there are zero output types in "
|
||||
+ AUDIT_ENABLED_SETTING.getKey());
|
||||
+ XPackSettings.AUDIT_ENABLED.getKey());
|
||||
}
|
||||
|
||||
for (String output : outputs) {
|
||||
|
@ -375,7 +367,7 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
SecurityNetty4HttpServerTransport.overrideSettings(settingsBuilder, settings);
|
||||
}
|
||||
|
||||
settingsBuilder.put(NetworkModule.TRANSPORT_SERVICE_TYPE_KEY, Security.NAME);
|
||||
settingsBuilder.put(NetworkModule.TRANSPORT_SERVICE_TYPE_KEY, XPackPlugin.SECURITY);
|
||||
addUserSettings(settings, settingsBuilder);
|
||||
addTribeSettings(settings, settingsBuilder);
|
||||
return settingsBuilder.build();
|
||||
|
@ -384,7 +376,6 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
public List<Setting<?>> getSettings() {
|
||||
List<Setting<?>> settingsList = new ArrayList<>();
|
||||
// always register for both client and node modes
|
||||
XPackPlugin.addFeatureEnabledSettings(settingsList, NAME, true);
|
||||
settingsList.add(USER_SETTING);
|
||||
|
||||
// SSL settings
|
||||
|
@ -398,13 +389,11 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
}
|
||||
|
||||
// The following just apply in node mode
|
||||
XPackPlugin.addFeatureEnabledSettings(settingsList, DLS_FLS_FEATURE, true);
|
||||
|
||||
// IP Filter settings
|
||||
IPFilter.addSettings(settingsList);
|
||||
|
||||
// audit settings
|
||||
settingsList.add(AUDIT_ENABLED_SETTING);
|
||||
settingsList.add(AUDIT_OUTPUTS_SETTING);
|
||||
LoggingAuditTrail.registerSettings(settingsList);
|
||||
IndexAuditTrail.registerSettings(settingsList);
|
||||
|
@ -456,7 +445,7 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
}
|
||||
|
||||
assert licenseState != null;
|
||||
if (flsDlsEnabled(settings)) {
|
||||
if (XPackSettings.DLS_FLS_ENABLED.get(settings)) {
|
||||
module.setSearcherWrapper(indexService ->
|
||||
new SecurityIndexSearcherWrapper(indexService.getIndexSettings(), indexService.newQueryShardContext(),
|
||||
indexService.mapperService(), indexService.cache().bitsetFilterCache(),
|
||||
|
@ -529,7 +518,7 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
if (enabled) {
|
||||
module.registerTransport(Security.NAME3, SecurityNetty3Transport.class);
|
||||
module.registerTransport(Security.NAME4, SecurityNetty4Transport.class);
|
||||
module.registerTransportService(Security.NAME, SecurityClientTransportService.class);
|
||||
module.registerTransportService(XPackPlugin.SECURITY, SecurityClientTransportService.class);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -537,7 +526,7 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
if (enabled) {
|
||||
module.registerTransport(Security.NAME3, SecurityNetty3Transport.class);
|
||||
module.registerTransport(Security.NAME4, SecurityNetty4Transport.class);
|
||||
module.registerTransportService(Security.NAME, SecurityServerTransportService.class);
|
||||
module.registerTransportService(XPackPlugin.SECURITY, SecurityServerTransportService.class);
|
||||
module.registerHttpTransport(Security.NAME3, SecurityNetty3HttpServerTransport.class);
|
||||
module.registerHttpTransport(Security.NAME4, SecurityNetty4HttpServerTransport.class);
|
||||
}
|
||||
|
@ -595,9 +584,9 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
final String tribeEnabledSetting = tribePrefix + XPackPlugin.featureEnabledSetting(NAME);
|
||||
final String tribeEnabledSetting = tribePrefix + XPackSettings.SECURITY_ENABLED.getKey();
|
||||
if (settings.get(tribeEnabledSetting) != null) {
|
||||
boolean enabled = enabled(tribeSettings.getValue());
|
||||
boolean enabled = XPackSettings.SECURITY_ENABLED.get(tribeSettings.getValue());
|
||||
if (!enabled) {
|
||||
throw new IllegalStateException("tribe setting [" + tribeEnabledSetting + "] must be set to true but the value is ["
|
||||
+ settings.get(tribeEnabledSetting) + "]");
|
||||
|
@ -617,20 +606,8 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean enabled(Settings settings) {
|
||||
return XPackPlugin.featureEnabled(settings, NAME, true);
|
||||
}
|
||||
|
||||
public static boolean flsDlsEnabled(Settings settings) {
|
||||
return XPackPlugin.featureEnabled(settings, DLS_FLS_FEATURE, true);
|
||||
}
|
||||
|
||||
public static String enabledSetting() {
|
||||
return XPackPlugin.featureEnabledSetting(NAME);
|
||||
}
|
||||
|
||||
public static String settingPrefix() {
|
||||
return XPackPlugin.featureSettingPrefix(NAME) + ".";
|
||||
return XPackPlugin.featureSettingPrefix(XPackPlugin.SECURITY) + ".";
|
||||
}
|
||||
|
||||
public static String setting(String setting) {
|
||||
|
@ -638,17 +615,8 @@ public class Security implements ActionPlugin, IngestPlugin {
|
|||
return settingPrefix() + setting;
|
||||
}
|
||||
|
||||
public static String featureEnabledSetting(String feature) {
|
||||
assert feature != null && feature.startsWith(".") == false;
|
||||
return XPackPlugin.featureEnabledSetting("security." + feature);
|
||||
}
|
||||
|
||||
public static boolean auditingEnabled(Settings settings) {
|
||||
return AUDIT_ENABLED_SETTING.get(settings);
|
||||
}
|
||||
|
||||
public static boolean indexAuditLoggingEnabled(Settings settings) {
|
||||
if (auditingEnabled(settings)) {
|
||||
static boolean indexAuditLoggingEnabled(Settings settings) {
|
||||
if (XPackSettings.AUDIT_ENABLED.get(settings)) {
|
||||
List<String> outputs = AUDIT_OUTPUTS_SETTING.get(settings);
|
||||
for (String output : outputs) {
|
||||
if (output.equals(IndexAuditTrail.NAME)) {
|
||||
|
|
|
@ -5,17 +5,23 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.security;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.xpack.XPackFeatureSet;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.audit.AuditTrailService;
|
||||
import org.elasticsearch.xpack.security.authc.Realms;
|
||||
import org.elasticsearch.xpack.XPackFeatureSet;
|
||||
import org.elasticsearch.xpack.security.authz.store.CompositeRolesStore;
|
||||
import org.elasticsearch.xpack.security.authz.store.RolesStore;
|
||||
import org.elasticsearch.xpack.security.crypto.CryptoService;
|
||||
|
@ -24,11 +30,6 @@ import org.elasticsearch.xpack.security.transport.netty3.SecurityNetty3HttpServe
|
|||
import org.elasticsearch.xpack.security.transport.netty3.SecurityNetty3Transport;
|
||||
import org.elasticsearch.xpack.security.user.AnonymousUser;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -54,7 +55,7 @@ public class SecurityFeatureSet implements XPackFeatureSet {
|
|||
public SecurityFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState, @Nullable Realms realms,
|
||||
@Nullable CompositeRolesStore rolesStore, @Nullable IPFilter ipFilter,
|
||||
@Nullable AuditTrailService auditTrailService, @Nullable CryptoService cryptoService) {
|
||||
this.enabled = Security.enabled(settings);
|
||||
this.enabled = XPackSettings.SECURITY_ENABLED.get(settings);
|
||||
this.licenseState = licenseState;
|
||||
this.realms = realms;
|
||||
this.rolesStore = rolesStore;
|
||||
|
@ -66,7 +67,7 @@ public class SecurityFeatureSet implements XPackFeatureSet {
|
|||
|
||||
@Override
|
||||
public String name() {
|
||||
return Security.NAME;
|
||||
return XPackPlugin.SECURITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -169,7 +170,7 @@ public class SecurityFeatureSet implements XPackFeatureSet {
|
|||
public Usage(boolean available, boolean enabled, Map<String, Object> realmsUsage, Map<String, Object> rolesStoreUsage,
|
||||
Map<String, Object> sslUsage, Map<String, Object> auditUsage, Map<String, Object> ipFilterUsage,
|
||||
Map<String, Object> systemKeyUsage, Map<String, Object> anonymousUsage) {
|
||||
super(Security.NAME, available, enabled);
|
||||
super(XPackPlugin.SECURITY, available, enabled);
|
||||
this.realmsUsage = realmsUsage;
|
||||
this.rolesStoreUsage = rolesStoreUsage;
|
||||
this.sslUsage = sslUsage;
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.security.action.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ActionRequest;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
|
@ -19,29 +25,23 @@ import org.elasticsearch.common.inject.Inject;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.license.LicenseUtils;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.tasks.Task;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.security.SecurityContext;
|
||||
import org.elasticsearch.xpack.security.action.SecurityActionMapper;
|
||||
import org.elasticsearch.xpack.security.action.interceptor.RequestInterceptor;
|
||||
import org.elasticsearch.xpack.security.audit.AuditTrail;
|
||||
import org.elasticsearch.xpack.security.audit.AuditTrailService;
|
||||
import org.elasticsearch.xpack.security.authc.Authentication;
|
||||
import org.elasticsearch.xpack.security.authc.AuthenticationService;
|
||||
import org.elasticsearch.xpack.security.authz.AuthorizationService;
|
||||
import org.elasticsearch.xpack.security.user.SystemUser;
|
||||
import org.elasticsearch.xpack.security.user.User;
|
||||
import org.elasticsearch.xpack.security.action.interceptor.RequestInterceptor;
|
||||
import org.elasticsearch.xpack.security.audit.AuditTrail;
|
||||
import org.elasticsearch.xpack.security.authz.AuthorizationUtils;
|
||||
import org.elasticsearch.xpack.security.authz.privilege.HealthAndStatsPrivilege;
|
||||
import org.elasticsearch.xpack.security.crypto.CryptoService;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.tasks.Task;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import org.elasticsearch.xpack.security.user.SystemUser;
|
||||
import org.elasticsearch.xpack.security.user.User;
|
||||
|
||||
import static org.elasticsearch.xpack.security.support.Exceptions.authorizationError;
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class SecurityActionFilter extends AbstractComponent implements ActionFil
|
|||
logger.error("blocking [{}] operation due to expired license. Cluster health, cluster stats and indices stats \n" +
|
||||
"operations are blocked on license expiration. All data operations (read and write) continue to work. \n" +
|
||||
"If you have a new license, please update it. Otherwise, please reach out to your support contact.", action);
|
||||
throw LicenseUtils.newComplianceException(Security.NAME);
|
||||
throw LicenseUtils.newComplianceException(XPackPlugin.SECURITY);
|
||||
}
|
||||
|
||||
// only restore the context if it is not empty. This is needed because sometimes a response is sent to the user
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.transport.TransportMessage;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.security.authc.AuthenticationToken;
|
||||
import org.elasticsearch.xpack.security.transport.filter.SecurityIpFilterRule;
|
||||
|
@ -209,7 +210,7 @@ public class AuditTrailService extends AbstractComponent implements AuditTrail {
|
|||
|
||||
public Map<String, Object> usageStats() {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("enabled", Security.AUDIT_ENABLED_SETTING.get(settings));
|
||||
map.put("enabled", XPackSettings.AUDIT_ENABLED.get(settings));
|
||||
map.put("outputs", Security.AUDIT_OUTPUTS_SETTING.get(settings));
|
||||
return map;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.elasticsearch.watcher.FileChangesListener;
|
|||
import org.elasticsearch.watcher.FileWatcher;
|
||||
import org.elasticsearch.watcher.ResourceWatcherService;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.authc.support.RefreshListener;
|
||||
import org.elasticsearch.xpack.security.authz.RoleDescriptor;
|
||||
import org.elasticsearch.xpack.security.authz.permission.IndicesPermission.Group;
|
||||
|
@ -201,10 +201,10 @@ public class FileRolesStore extends AbstractLifecycleComponent implements RolesS
|
|||
// first check if FLS/DLS is enabled on the role...
|
||||
for (RoleDescriptor.IndicesPrivileges privilege : descriptor.getIndicesPrivileges()) {
|
||||
if ((privilege.getQuery() != null || privilege.getFields() != null)
|
||||
&& Security.flsDlsEnabled(settings) == false) {
|
||||
&& XPackSettings.DLS_FLS_ENABLED.get(settings) == false) {
|
||||
logger.error("invalid role definition [{}] in roles file [{}]. document and field level security is not " +
|
||||
"enabled. set [{}] to [true] in the configuration file. skipping role...", roleName, path
|
||||
.toAbsolutePath(), XPackPlugin.featureEnabledSetting(Security.DLS_FLS_FEATURE));
|
||||
.toAbsolutePath(), XPackSettings.DLS_FLS_ENABLED.getKey());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.client.Client;
|
|||
import org.elasticsearch.client.transport.TransportClient;
|
||||
import org.elasticsearch.common.inject.AbstractModule;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -23,7 +23,7 @@ public abstract class AbstractSecurityModule extends AbstractModule {
|
|||
public AbstractSecurityModule(Settings settings) {
|
||||
this.settings = settings;
|
||||
this.clientMode = TransportClient.CLIENT_TYPE.equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey()));
|
||||
this.securityEnabled = Security.enabled(settings);
|
||||
this.securityEnabled = XPackSettings.SECURITY_ENABLED.get(settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,7 +7,7 @@ package org.elasticsearch.xpack.security.support;
|
|||
|
||||
import org.elasticsearch.ElasticsearchSecurityException;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -19,13 +19,13 @@ public class Exceptions {
|
|||
|
||||
public static ElasticsearchSecurityException authenticationError(String msg, Throwable cause, Object... args) {
|
||||
ElasticsearchSecurityException e = new ElasticsearchSecurityException(msg, RestStatus.UNAUTHORIZED, cause, args);
|
||||
e.addHeader("WWW-Authenticate", "Basic realm=\"" + Security.NAME + "\" charset=\"UTF-8\"");
|
||||
e.addHeader("WWW-Authenticate", "Basic realm=\"" + XPackPlugin.SECURITY + "\" charset=\"UTF-8\"");
|
||||
return e;
|
||||
}
|
||||
|
||||
public static ElasticsearchSecurityException authenticationError(String msg, Object... args) {
|
||||
ElasticsearchSecurityException e = new ElasticsearchSecurityException(msg, RestStatus.UNAUTHORIZED, args);
|
||||
e.addHeader("WWW-Authenticate", "Basic realm=\"" + Security.NAME + "\" charset=\"UTF-8\"");
|
||||
e.addHeader("WWW-Authenticate", "Basic realm=\"" + XPackPlugin.SECURITY + "\" charset=\"UTF-8\"");
|
||||
return e;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ import java.io.IOException;
|
|||
import java.net.InetSocketAddress;
|
||||
import java.util.List;
|
||||
|
||||
import static org.elasticsearch.xpack.security.Security.featureEnabledSetting;
|
||||
import static org.elasticsearch.xpack.security.Security.setting;
|
||||
import static org.elasticsearch.xpack.security.Security.settingPrefix;
|
||||
import static org.elasticsearch.xpack.security.transport.SSLExceptionHelper.isCloseDuringHandshakeException;
|
||||
|
@ -53,7 +52,7 @@ public class SecurityNetty3Transport extends Netty3Transport {
|
|||
new Property[]{Property.NodeScope, Property.Filtered, Property.Deprecated, Property.Shared});
|
||||
|
||||
public static final Setting<Boolean> HOSTNAME_VERIFICATION_SETTING =
|
||||
Setting.boolSetting(featureEnabledSetting("ssl.hostname_verification"), DEPRECATED_HOSTNAME_VERIFICATION_SETTING,
|
||||
Setting.boolSetting(setting("ssl.hostname_verification.enabled"), DEPRECATED_HOSTNAME_VERIFICATION_SETTING,
|
||||
Property.NodeScope, Property.Filtered, Property.Shared);
|
||||
|
||||
public static final Setting<Boolean> HOSTNAME_VERIFICATION_RESOLVE_NAME_SETTING =
|
||||
|
|
|
@ -40,7 +40,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.elasticsearch.xpack.security.Security.featureEnabledSetting;
|
||||
import static org.elasticsearch.xpack.security.Security.setting;
|
||||
import static org.elasticsearch.xpack.security.Security.settingPrefix;
|
||||
|
||||
|
@ -60,7 +59,7 @@ public class SecurityNetty4Transport extends Netty4Transport {
|
|||
new Property[]{Property.NodeScope, Property.Filtered, Property.Deprecated, Property.Shared});
|
||||
|
||||
public static final Setting<Boolean> HOSTNAME_VERIFICATION_SETTING =
|
||||
Setting.boolSetting(featureEnabledSetting("ssl.hostname_verification"), DEPRECATED_HOSTNAME_VERIFICATION_SETTING,
|
||||
Setting.boolSetting(setting("ssl.hostname_verification.enabled"), DEPRECATED_HOSTNAME_VERIFICATION_SETTING,
|
||||
Property.NodeScope, Property.Filtered, Property.Shared);
|
||||
|
||||
public static final Setting<Boolean> HOSTNAME_VERIFICATION_RESOLVE_NAME_SETTING =
|
||||
|
|
|
@ -18,8 +18,7 @@ import org.elasticsearch.common.network.NetworkModule;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||
import org.elasticsearch.test.SecuritySettingsSource;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
||||
import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken;
|
||||
|
||||
|
@ -36,7 +35,7 @@ public class BulkUpdateTests extends SecurityIntegTestCase {
|
|||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.DLS_FLS_FEATURE), randomBoolean())
|
||||
.put(XPackSettings.DLS_FLS_ENABLED.getKey(), randomBoolean())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,14 +8,12 @@ package org.elasticsearch.integration;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.IndexModule;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.authc.support.Hasher;
|
||||
import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -89,7 +87,7 @@ public class DocumentAndFieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.DLS_FLS_FEATURE), true)
|
||||
.put(XPackSettings.DLS_FLS_ENABLED.getKey(), true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,10 @@ import org.elasticsearch.action.index.IndexRequestBuilder;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.authc.support.Hasher;
|
||||
import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -88,7 +87,7 @@ public class DocumentLevelSecurityRandomTests extends SecurityIntegTestCase {
|
|||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.DLS_FLS_FEATURE), true)
|
||||
.put(XPackSettings.DLS_FLS_ENABLED.getKey(), true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,11 +25,10 @@ import org.elasticsearch.search.aggregations.bucket.children.Children;
|
|||
import org.elasticsearch.search.aggregations.bucket.global.Global;
|
||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.authc.support.Hasher;
|
||||
import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -100,7 +99,7 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
|||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.DLS_FLS_FEATURE), true)
|
||||
.put(XPackSettings.DLS_FLS_ENABLED.getKey(), true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,10 @@ import org.elasticsearch.action.search.SearchResponse;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.authc.support.Hasher;
|
||||
import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -121,7 +120,7 @@ public class FieldLevelSecurityRandomTests extends SecurityIntegTestCase {
|
|||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.DLS_FLS_FEATURE), true)
|
||||
.put(XPackSettings.DLS_FLS_ENABLED.getKey(), true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,12 +23,11 @@ import org.elasticsearch.rest.RestStatus;
|
|||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.authc.support.Hasher;
|
||||
import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -129,7 +128,7 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.DLS_FLS_FEATURE), true)
|
||||
.put(XPackSettings.DLS_FLS_ENABLED.getKey(), true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,10 @@ package org.elasticsearch.integration;
|
|||
import org.elasticsearch.action.admin.indices.alias.Alias;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.authc.support.Hasher;
|
||||
import org.elasticsearch.xpack.security.authc.support.SecuredString;
|
||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
|
@ -62,7 +61,7 @@ public class IndicesPermissionsWithAliasesWildcardsAndRegexsTests extends Securi
|
|||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.DLS_FLS_FEATURE), true)
|
||||
.put(XPackSettings.DLS_FLS_ENABLED.getKey(), true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.test.SecuritySettingsSource;
|
|||
import org.elasticsearch.transport.Netty3Plugin;
|
||||
import org.elasticsearch.transport.Netty4Plugin;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackTransportClient;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.security.authc.support.UsernamePasswordToken;
|
||||
|
@ -197,7 +198,7 @@ public class LicensingTests extends SecurityIntegTestCase {
|
|||
|
||||
private static void assertElasticsearchSecurityException(ThrowingRunnable runnable) {
|
||||
ElasticsearchSecurityException ee = expectThrows(ElasticsearchSecurityException.class, runnable);
|
||||
assertThat(ee.getHeader("es.license.expired.feature"), hasItem(Security.NAME));
|
||||
assertThat(ee.getHeader("es.license.expired.feature"), hasItem(XPackPlugin.SECURITY));
|
||||
assertThat(ee.status(), is(RestStatus.FORBIDDEN));
|
||||
}
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ import java.util.stream.Collectors;
|
|||
|
||||
import org.elasticsearch.license.License.OperationMode;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.monitoring.Monitoring;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.hamcrest.Matchers;
|
||||
|
||||
import static org.elasticsearch.license.License.OperationMode.MISSING;
|
||||
import static org.elasticsearch.license.License.OperationMode.BASIC;
|
||||
import static org.elasticsearch.license.License.OperationMode.GOLD;
|
||||
import static org.elasticsearch.license.License.OperationMode.MISSING;
|
||||
import static org.elasticsearch.license.License.OperationMode.PLATINUM;
|
||||
import static org.elasticsearch.license.License.OperationMode.STANDARD;
|
||||
import static org.elasticsearch.license.License.OperationMode.TRIAL;
|
||||
|
@ -168,25 +168,25 @@ public class XPackLicenseStateTests extends ESTestCase {
|
|||
|
||||
public void testSecurityAckBasicToNotGoldOrStandard() {
|
||||
OperationMode toMode = randomFrom(OperationMode.values(), mode -> mode != GOLD && mode != STANDARD);
|
||||
assertAckMesssages(Security.NAME, BASIC, toMode, 0);
|
||||
assertAckMesssages(XPackPlugin.SECURITY, BASIC, toMode, 0);
|
||||
}
|
||||
|
||||
public void testSecurityAckAnyToTrialOrPlatinum() {
|
||||
assertAckMesssages(Security.NAME, randomMode(), randomTrialOrPlatinumMode(), 0);
|
||||
assertAckMesssages(XPackPlugin.SECURITY, randomMode(), randomTrialOrPlatinumMode(), 0);
|
||||
}
|
||||
|
||||
public void testSecurityAckTrialStandardGoldOrPlatinumToBasic() {
|
||||
assertAckMesssages(Security.NAME, randomTrialStandardGoldOrPlatinumMode(), BASIC, 3);
|
||||
assertAckMesssages(XPackPlugin.SECURITY, randomTrialStandardGoldOrPlatinumMode(), BASIC, 3);
|
||||
}
|
||||
|
||||
public void testSecurityAckAnyToStandard() {
|
||||
OperationMode from = randomFrom(BASIC, GOLD, PLATINUM, TRIAL);
|
||||
assertAckMesssages(Security.NAME, from, STANDARD, 4);
|
||||
assertAckMesssages(XPackPlugin.SECURITY, from, STANDARD, 4);
|
||||
}
|
||||
|
||||
public void testSecurityAckBasicStandardTrialOrPlatinumToGold() {
|
||||
OperationMode from = randomFrom(BASIC, PLATINUM, TRIAL, STANDARD);
|
||||
assertAckMesssages(Security.NAME, from, GOLD, 2);
|
||||
assertAckMesssages(XPackPlugin.SECURITY, from, GOLD, 2);
|
||||
}
|
||||
|
||||
public void testMonitoringAckBasicToAny() {
|
||||
|
|
|
@ -11,9 +11,9 @@ import org.elasticsearch.common.io.PathUtils;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.discovery.DiscoveryModule;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.transport.Netty3Plugin;
|
||||
import org.elasticsearch.transport.Netty4Plugin;
|
||||
import org.elasticsearch.xpack.monitoring.Monitoring;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||
import org.elasticsearch.xpack.security.authc.file.FileRealm;
|
||||
|
@ -28,7 +28,6 @@ import org.elasticsearch.xpack.security.test.SecurityTestUtils;
|
|||
import org.elasticsearch.xpack.security.transport.netty3.SecurityNetty3HttpServerTransport;
|
||||
import org.elasticsearch.xpack.security.transport.netty3.SecurityNetty3Transport;
|
||||
import org.elasticsearch.test.discovery.ClusterDiscoveryConfiguration;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -127,9 +126,9 @@ public class SecuritySettingsSource extends ClusterDiscoveryConfiguration.Unicas
|
|||
Settings.Builder builder = Settings.builder().put(super.nodeSettings(nodeOrdinal))
|
||||
|
||||
//TODO: for now isolate security tests from watcher & monitoring (randomize this later)
|
||||
.put(XPackPlugin.featureEnabledSetting(Watcher.NAME), false)
|
||||
.put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false)
|
||||
.put(Security.AUDIT_ENABLED_SETTING.getKey(), randomBoolean())
|
||||
.put(XPackSettings.WATCHER_ENABLED.getKey(), false)
|
||||
.put(XPackSettings.MONITORING_ENABLED.getKey(), false)
|
||||
.put(XPackSettings.AUDIT_ENABLED.getKey(), randomBoolean())
|
||||
.put(LoggingAuditTrail.HOST_ADDRESS_SETTING.getKey(), randomBoolean())
|
||||
.put(LoggingAuditTrail.HOST_NAME_SETTING.getKey(), randomBoolean())
|
||||
.put(LoggingAuditTrail.NODE_NAME_SETTING.getKey(), randomBoolean())
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
*/
|
||||
package org.elasticsearch.transport;
|
||||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.security.transport.SecurityServerTransportService;
|
||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.test.SecurityIntegTestCase;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.transport.SecurityServerTransportService;
|
||||
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
|
||||
|
@ -21,7 +21,7 @@ public class SecurityServerTransportServiceTests extends SecurityIntegTestCase {
|
|||
protected Settings transportClientSettings() {
|
||||
return Settings.builder()
|
||||
.put(super.transportClientSettings())
|
||||
.put(Security.enabledSetting(), true)
|
||||
.put(XPackSettings.SECURITY_ENABLED.getKey(), true)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.XPackFeatureSet;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.security.audit.AuditTrailService;
|
||||
import org.elasticsearch.xpack.security.authc.Realms;
|
||||
import org.elasticsearch.xpack.security.authz.store.CompositeRolesStore;
|
||||
|
@ -157,7 +158,7 @@ public class SecurityFeatureSetTests extends ESTestCase {
|
|||
ipFilter, auditTrail, cryptoService);
|
||||
XPackFeatureSet.Usage usage = featureSet.usage();
|
||||
assertThat(usage, is(notNullValue()));
|
||||
assertThat(usage.name(), is(Security.NAME));
|
||||
assertThat(usage.name(), is(XPackPlugin.SECURITY));
|
||||
assertThat(usage.enabled(), is(enabled));
|
||||
assertThat(usage.available(), is(authcAuthzAvailable));
|
||||
XContentSource source = new XContentSource(usage);
|
||||
|
|
|
@ -9,9 +9,10 @@ import java.io.IOException;
|
|||
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
|
@ -23,8 +24,8 @@ import static org.hamcrest.Matchers.not;
|
|||
|
||||
public class SecuritySettingsTests extends ESTestCase {
|
||||
|
||||
private static final String TRIBE_T1_SECURITY_ENABLED = "tribe.t1." + Security.enabledSetting();
|
||||
private static final String TRIBE_T2_SECURITY_ENABLED = "tribe.t2." + Security.enabledSetting();
|
||||
private static final String TRIBE_T1_SECURITY_ENABLED = "tribe.t1." + XPackSettings.SECURITY_ENABLED.getKey();
|
||||
private static final String TRIBE_T2_SECURITY_ENABLED = "tribe.t2." + XPackSettings.SECURITY_ENABLED.getKey();
|
||||
|
||||
public void testSecurityIsMandatoryOnTribes() throws IOException {
|
||||
Settings settings = Settings.builder().put("tribe.t1.cluster.name", "non_existing")
|
||||
|
@ -157,13 +158,13 @@ public class SecuritySettingsTests extends ESTestCase {
|
|||
|
||||
Security.validateAutoCreateIndex(Settings.builder()
|
||||
.put("action.auto_create_index", ".security")
|
||||
.put(Security.AUDIT_ENABLED_SETTING.getKey(), true)
|
||||
.put(XPackSettings.AUDIT_ENABLED.getKey(), true)
|
||||
.build());
|
||||
|
||||
try {
|
||||
Security.validateAutoCreateIndex(Settings.builder()
|
||||
.put("action.auto_create_index", ".security")
|
||||
.put(Security.AUDIT_ENABLED_SETTING.getKey(), true)
|
||||
.put(XPackSettings.AUDIT_ENABLED.getKey(), true)
|
||||
.put(Security.AUDIT_OUTPUTS_SETTING.getKey(), randomFrom("index", "logfile,index"))
|
||||
.build());
|
||||
fail("IllegalArgumentException expected");
|
||||
|
@ -174,7 +175,7 @@ public class SecuritySettingsTests extends ESTestCase {
|
|||
|
||||
Security.validateAutoCreateIndex(Settings.builder()
|
||||
.put("action.auto_create_index", ".security_audit_log*,.security")
|
||||
.put(Security.AUDIT_ENABLED_SETTING.getKey(), true)
|
||||
.put(XPackSettings.AUDIT_ENABLED.getKey(), true)
|
||||
.put(Security.AUDIT_OUTPUTS_SETTING.getKey(), randomFrom("index", "logfile,index"))
|
||||
.build());
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.elasticsearch.env.Environment;
|
|||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.extensions.XPackExtension;
|
||||
import org.elasticsearch.xpack.security.audit.AuditTrailService;
|
||||
import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail;
|
||||
|
@ -84,7 +85,7 @@ public class SecurityTests extends ESTestCase {
|
|||
|
||||
|
||||
public void testAuditEnabled() throws Exception {
|
||||
Settings settings = Settings.builder().put(Security.AUDIT_ENABLED_SETTING.getKey(), true).build();
|
||||
Settings settings = Settings.builder().put(XPackSettings.AUDIT_ENABLED.getKey(), true).build();
|
||||
Collection<Object> components = createComponents(settings);
|
||||
AuditTrailService service = findComponent(AuditTrailService.class, components);
|
||||
assertNotNull(service);
|
||||
|
@ -100,7 +101,7 @@ public class SecurityTests extends ESTestCase {
|
|||
|
||||
public void testIndexAuditTrail() throws Exception {
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.AUDIT_ENABLED_SETTING.getKey(), true)
|
||||
.put(XPackSettings.AUDIT_ENABLED.getKey(), true)
|
||||
.put(Security.AUDIT_OUTPUTS_SETTING.getKey(), "index").build();
|
||||
Collection<Object> components = createComponents(settings);
|
||||
AuditTrailService service = findComponent(AuditTrailService.class, components);
|
||||
|
@ -111,7 +112,7 @@ public class SecurityTests extends ESTestCase {
|
|||
|
||||
public void testIndexAndLoggingAuditTrail() throws Exception {
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.AUDIT_ENABLED_SETTING.getKey(), true)
|
||||
.put(XPackSettings.AUDIT_ENABLED.getKey(), true)
|
||||
.put(Security.AUDIT_OUTPUTS_SETTING.getKey(), "index,logfile").build();
|
||||
Collection<Object> components = createComponents(settings);
|
||||
AuditTrailService service = findComponent(AuditTrailService.class, components);
|
||||
|
@ -123,7 +124,7 @@ public class SecurityTests extends ESTestCase {
|
|||
|
||||
public void testUnknownOutput() throws Exception {
|
||||
Settings settings = Settings.builder()
|
||||
.put(Security.AUDIT_ENABLED_SETTING.getKey(), true)
|
||||
.put(XPackSettings.AUDIT_ENABLED.getKey(), true)
|
||||
.put(Security.AUDIT_OUTPUTS_SETTING.getKey(), "foo").build();
|
||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> createComponents(settings));
|
||||
assertEquals("Unknown audit trail output [foo]", e.getMessage());
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.elasticsearch.transport.MockTcpTransportPlugin;
|
|||
import org.elasticsearch.transport.TransportInfo;
|
||||
import org.elasticsearch.transport.TransportMessage;
|
||||
import org.elasticsearch.transport.TransportRequest;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.audit.index.IndexAuditTrail.Message;
|
||||
import org.elasticsearch.xpack.security.authc.AuthenticationToken;
|
||||
import org.elasticsearch.xpack.security.crypto.CryptoService;
|
||||
|
@ -140,7 +140,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
public Settings nodeSettings(int nodeOrdinal) {
|
||||
Settings.Builder builder = Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(Security.enabledSetting(), useSecurity);
|
||||
.put(XPackSettings.SECURITY_ENABLED.getKey(), useSecurity);
|
||||
if (useSecurity == false && builder.get(NetworkModule.TRANSPORT_TYPE_KEY) == null) {
|
||||
builder.put(NetworkModule.TRANSPORT_TYPE_KEY, MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME);
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ public class IndexAuditTrailTests extends SecurityIntegTestCase {
|
|||
InetSocketTransportAddress inet = (InetSocketTransportAddress) info.address().publishAddress();
|
||||
|
||||
Settings.Builder builder = Settings.builder()
|
||||
.put(Security.enabledSetting(), useSecurity)
|
||||
.put(XPackSettings.SECURITY_ENABLED.getKey(), useSecurity)
|
||||
.put(remoteSettings(NetworkAddress.format(inet.address().getAddress()), inet.address().getPort(), cluster2Name))
|
||||
.put("xpack.security.audit.index.client.xpack.security.user", SecuritySettingsSource.DEFAULT_USER_NAME + ":" +
|
||||
SecuritySettingsSource.DEFAULT_PASSWORD);
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.elasticsearch.common.logging.ESLogger;
|
|||
import org.elasticsearch.common.logging.ESLoggerFactory;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.audit.logfile.CapturingLogger;
|
||||
import org.elasticsearch.xpack.security.authc.RealmConfig;
|
||||
import org.elasticsearch.xpack.security.authc.support.RefreshListener;
|
||||
|
@ -18,8 +19,6 @@ import org.elasticsearch.test.ESTestCase;
|
|||
import org.elasticsearch.threadpool.TestThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.watcher.ResourceWatcherService;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
|
@ -226,7 +225,7 @@ public class FileUserRolesStoreTests extends ESTestCase {
|
|||
Path usersRoles = writeUsersRoles("role1:admin");
|
||||
|
||||
Settings settings = Settings.builder()
|
||||
.put(XPackPlugin.featureEnabledSetting(Watcher.NAME), "false")
|
||||
.put(XPackSettings.WATCHER_ENABLED.getKey(), "false")
|
||||
.put("path.home", createTempDir())
|
||||
.build();
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.security.authz.store;
|
|||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.security.audit.logfile.CapturingLogger;
|
||||
import org.elasticsearch.xpack.security.authc.support.RefreshListener;
|
||||
|
@ -56,7 +57,7 @@ public class FileRolesStoreTests extends ESTestCase {
|
|||
public void testParseFile() throws Exception {
|
||||
Path path = getDataPath("roles.yml");
|
||||
Map<String, Role> roles = FileRolesStore.parseFile(path, logger, Settings.builder()
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.DLS_FLS_FEATURE), true)
|
||||
.put(XPackSettings.DLS_FLS_ENABLED.getKey(), true)
|
||||
.build());
|
||||
assertThat(roles, notNullValue());
|
||||
assertThat(roles.size(), is(9));
|
||||
|
@ -209,7 +210,7 @@ public class FileRolesStoreTests extends ESTestCase {
|
|||
Path path = getDataPath("roles.yml");
|
||||
CapturingLogger logger = new CapturingLogger(CapturingLogger.Level.ERROR);
|
||||
Map<String, Role> roles = FileRolesStore.parseFile(path, logger, Settings.builder()
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.DLS_FLS_FEATURE), false)
|
||||
.put(XPackSettings.DLS_FLS_ENABLED.getKey(), false)
|
||||
.build());
|
||||
assertThat(roles, notNullValue());
|
||||
assertThat(roles.size(), is(6));
|
||||
|
@ -378,7 +379,7 @@ public class FileRolesStoreTests extends ESTestCase {
|
|||
.put("resource.reload.interval.high", "500ms")
|
||||
.put(FileRolesStore.ROLES_FILE_SETTING.getKey(), tmp.toAbsolutePath())
|
||||
.put("path.home", createTempDir())
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.DLS_FLS_FEATURE), flsDlsEnabled)
|
||||
.put(XPackSettings.DLS_FLS_ENABLED.getKey(), flsDlsEnabled)
|
||||
.build();
|
||||
Environment env = new Environment(settings);
|
||||
FileRolesStore store = new FileRolesStore(settings, env, mock(ResourceWatcherService.class));
|
||||
|
|
|
@ -7,7 +7,7 @@ package org.elasticsearch.xpack.security.test;
|
|||
|
||||
import org.elasticsearch.ElasticsearchSecurityException;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
|
@ -21,6 +21,6 @@ public class SecurityAssertions {
|
|||
assertThat(e.status(), is(RestStatus.UNAUTHORIZED));
|
||||
assertThat(e.getHeaderKeys(), hasSize(1));
|
||||
assertThat(e.getHeader("WWW-Authenticate"), notNullValue());
|
||||
assertThat(e.getHeader("WWW-Authenticate"), contains("Basic realm=\"" + Security.NAME + "\" charset=\"UTF-8\""));
|
||||
assertThat(e.getHeader("WWW-Authenticate"), contains("Basic realm=\"" + XPackPlugin.SECURITY + "\" charset=\"UTF-8\""));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.logging.LoggerMessageFormat;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.License.OperationMode;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.graph.Graph;
|
||||
import org.elasticsearch.xpack.monitoring.Monitoring;
|
||||
import org.elasticsearch.xpack.monitoring.MonitoringSettings;
|
||||
|
@ -29,20 +30,20 @@ public class XPackLicenseState {
|
|||
static final Map<String, String[]> EXPIRATION_MESSAGES;
|
||||
static {
|
||||
Map<String, String[]> messages = new LinkedHashMap<>();
|
||||
messages.put(Security.NAME, new String[] {
|
||||
messages.put(XPackPlugin.SECURITY, new String[] {
|
||||
"Cluster health, cluster stats and indices stats operations are blocked",
|
||||
"All data operations (read and write) continue to work"
|
||||
});
|
||||
messages.put(Watcher.NAME, new String[] {
|
||||
messages.put(XPackPlugin.WATCHER, new String[] {
|
||||
"PUT / GET watch APIs are disabled, DELETE watch API continues to work",
|
||||
"Watches execute and write to the history",
|
||||
"The actions of the watches don't execute"
|
||||
});
|
||||
messages.put(Monitoring.NAME, new String[] {
|
||||
messages.put(XPackPlugin.MONITORING, new String[] {
|
||||
"The agent will stop collecting cluster and indices metrics",
|
||||
"The agent will stop automatically cleaning indices older than [xpack.monitoring.history.duration]"
|
||||
});
|
||||
messages.put(Graph.NAME, new String[] {
|
||||
messages.put(XPackPlugin.GRAPH, new String[] {
|
||||
"Graph explore APIs are disabled"
|
||||
});
|
||||
EXPIRATION_MESSAGES = Collections.unmodifiableMap(messages);
|
||||
|
@ -55,10 +56,10 @@ public class XPackLicenseState {
|
|||
static final Map<String, BiFunction<OperationMode, OperationMode, String[]>> ACKNOWLEDGMENT_MESSAGES;
|
||||
static {
|
||||
Map<String, BiFunction<OperationMode, OperationMode, String[]>> messages = new LinkedHashMap<>();
|
||||
messages.put(Security.NAME, XPackLicenseState::securityAcknowledgementMessages);
|
||||
messages.put(Watcher.NAME, XPackLicenseState::watcherAcknowledgementMessages);
|
||||
messages.put(Monitoring.NAME, XPackLicenseState::monitoringAcknowledgementMessages);
|
||||
messages.put(Graph.NAME, XPackLicenseState::graphAcknowledgementMessages);
|
||||
messages.put(XPackPlugin.SECURITY, XPackLicenseState::securityAcknowledgementMessages);
|
||||
messages.put(XPackPlugin.WATCHER, XPackLicenseState::watcherAcknowledgementMessages);
|
||||
messages.put(XPackPlugin.MONITORING, XPackLicenseState::monitoringAcknowledgementMessages);
|
||||
messages.put(XPackPlugin.GRAPH, XPackLicenseState::graphAcknowledgementMessages);
|
||||
ACKNOWLEDGMENT_MESSAGES = Collections.unmodifiableMap(messages);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,8 +98,20 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
|
|||
|
||||
public static final String NAME = "x-pack";
|
||||
|
||||
/** Name constant for the security feature. */
|
||||
public static final String SECURITY = "security";
|
||||
|
||||
/** Name constant for the monitoring feature. */
|
||||
public static final String MONITORING = "monitoring";
|
||||
|
||||
/** Name constant for the watcher feature. */
|
||||
public static final String WATCHER = "watcher";
|
||||
|
||||
/** Name constant for the graph feature. */
|
||||
public static final String GRAPH = "graph";
|
||||
|
||||
// inside of YAML settings we still use xpack do not having handle issues with dashes
|
||||
public static final String SETTINGS_NAME = "xpack";
|
||||
private static final String SETTINGS_NAME = "xpack";
|
||||
|
||||
// TODO: clean up this library to not ask for write access to all system properties!
|
||||
static {
|
||||
|
@ -274,8 +286,10 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
|
|||
settings.addAll(security.getSettings());
|
||||
settings.addAll(MonitoringSettings.getSettings());
|
||||
settings.addAll(watcher.getSettings());
|
||||
settings.addAll(graph.getSettings());
|
||||
settings.addAll(licensing.getSettings());
|
||||
|
||||
settings.addAll(XPackSettings.getAllSettings());
|
||||
|
||||
// we add the `xpack.version` setting to all internal indices
|
||||
settings.add(Setting.simpleString("index.xpack.version", Setting.Property.IndexScope));
|
||||
|
||||
|
@ -360,10 +374,10 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
|
|||
@Override
|
||||
public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
|
||||
return Arrays.asList(
|
||||
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, Security.NAME, SecurityFeatureSet.Usage::new),
|
||||
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, Watcher.NAME, WatcherFeatureSet.Usage::new),
|
||||
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, Monitoring.NAME, MonitoringFeatureSet.Usage::new),
|
||||
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, Graph.NAME, GraphFeatureSet.Usage::new)
|
||||
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, SECURITY, SecurityFeatureSet.Usage::new),
|
||||
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, WATCHER, WatcherFeatureSet.Usage::new),
|
||||
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, MONITORING, MonitoringFeatureSet.Usage::new),
|
||||
new NamedWriteableRegistry.Entry(XPackFeatureSet.Usage.class, GRAPH, GraphFeatureSet.Usage::new)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -394,47 +408,10 @@ public class XPackPlugin extends Plugin implements ScriptPlugin, ActionPlugin, I
|
|||
return env.configFile().resolve(NAME).resolve(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* A consistent way to enable disable features using the following setting:
|
||||
*
|
||||
* {@code "xpack.<feature>.enabled": true | false}
|
||||
*
|
||||
* Also supports the following setting as a fallback (for BWC with 1.x/2.x):
|
||||
*
|
||||
* {@code "<feature>.enabled": true | false}
|
||||
*/
|
||||
public static boolean featureEnabled(Settings settings, String featureName, boolean defaultValue) {
|
||||
return settings.getAsBoolean(featureEnabledSetting(featureName),
|
||||
settings.getAsBoolean(legacyFeatureEnabledSetting(featureName), defaultValue)); // for bwc
|
||||
}
|
||||
|
||||
public static String featureEnabledSetting(String featureName) {
|
||||
return featureSettingPrefix(featureName) + ".enabled";
|
||||
}
|
||||
|
||||
public static String featureSettingPrefix(String featureName) {
|
||||
return SETTINGS_NAME + "." + featureName;
|
||||
}
|
||||
|
||||
public static String legacyFeatureEnabledSetting(String featureName) {
|
||||
return featureName + ".enabled";
|
||||
}
|
||||
|
||||
/**
|
||||
* A consistent way to register the settings used to enable disable features, supporting the following format:
|
||||
*
|
||||
* {@code "xpack.<feature>.enabled": true | false}
|
||||
*
|
||||
* Also supports the following setting as a fallback (for BWC with 1.x/2.x):
|
||||
*
|
||||
* {@code "<feature>.enabled": true | false}
|
||||
*/
|
||||
public static void addFeatureEnabledSettings(List<Setting<?>> settingsList, String featureName, boolean defaultValue) {
|
||||
settingsList.add(Setting.boolSetting(featureEnabledSetting(featureName), defaultValue, Setting.Property.NodeScope));
|
||||
settingsList.add(Setting.boolSetting(legacyFeatureEnabledSetting(featureName),
|
||||
defaultValue, Setting.Property.NodeScope));
|
||||
}
|
||||
|
||||
public static Path resolveXPackExtensionsFile(Environment env) {
|
||||
return env.pluginsFile().resolve(XPackPlugin.NAME).resolve("extensions");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
||||
/**
|
||||
* A container for xpack setting constants.
|
||||
*/
|
||||
public class XPackSettings {
|
||||
/** All setting constants created in this class. */
|
||||
private static final List<Setting<?>> ALL_SETTINGS = new ArrayList<>();
|
||||
|
||||
/** Setting for enabling or disabling security. Defaults to true. */
|
||||
public static final Setting<Boolean> SECURITY_ENABLED = enabledSetting(XPackPlugin.SECURITY, true);
|
||||
|
||||
/** Setting for enabling or disabling monitoring. Defaults to true if not a tribe node. */
|
||||
public static final Setting<Boolean> MONITORING_ENABLED = enabledSetting(XPackPlugin.MONITORING,
|
||||
// By default, monitoring is disabled on tribe nodes
|
||||
s -> String.valueOf(XPackPlugin.isTribeNode(s) == false && XPackPlugin.isTribeClientNode(s) == false));
|
||||
|
||||
/** Setting for enabling or disabling watcher. Defaults to true. */
|
||||
public static final Setting<Boolean> WATCHER_ENABLED = enabledSetting(XPackPlugin.WATCHER, true);
|
||||
|
||||
/** Setting for enabling or disabling graph. Defaults to true. */
|
||||
public static final Setting<Boolean> GRAPH_ENABLED = enabledSetting(XPackPlugin.GRAPH, true);
|
||||
|
||||
/** Setting for enabling or disabling auditing. Defaults to false. */
|
||||
public static final Setting<Boolean> AUDIT_ENABLED = enabledSetting(XPackPlugin.SECURITY + ".audit", false);
|
||||
|
||||
/** Setting for enabling or disabling document/field level security. Defaults to true. */
|
||||
public static final Setting<Boolean> DLS_FLS_ENABLED = enabledSetting(XPackPlugin.SECURITY + ".dls_fls", true);
|
||||
|
||||
/**
|
||||
* Create a Setting for the enabled state of features in xpack.
|
||||
*
|
||||
* The given feature by be enabled or disabled with:
|
||||
* {@code "xpack.<feature>.enabled": true | false}
|
||||
*
|
||||
* For backward compatibility with 1.x and 2.x, the following also works:
|
||||
* {@code "<feature>.enabled": true | false}
|
||||
*
|
||||
* @param featureName The name of the feature in xpack
|
||||
* @param defaultValue True if the feature should be enabled by defualt, false otherwise
|
||||
*/
|
||||
private static Setting<Boolean> enabledSetting(String featureName, boolean defaultValue) {
|
||||
return enabledSetting(featureName, s -> String.valueOf(defaultValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a setting for the enabled state of a feature, with a complex default value.
|
||||
* @param featureName The name of the feature in xpack
|
||||
* @param defaultValueFn A function to determine the default value based on the existing settings
|
||||
* @see #enabledSetting(String,boolean)
|
||||
*/
|
||||
private static Setting<Boolean> enabledSetting(String featureName, Function<Settings,String> defaultValueFn) {
|
||||
String fallbackName = featureName + ".enabled";
|
||||
Setting<Boolean> fallback = Setting.boolSetting(fallbackName, defaultValueFn,
|
||||
Setting.Property.NodeScope, Setting.Property.Deprecated);
|
||||
String settingName = XPackPlugin.featureSettingPrefix(featureName) + ".enabled";
|
||||
Setting<Boolean> setting = Setting.boolSetting(settingName, fallback, Setting.Property.NodeScope);
|
||||
ALL_SETTINGS.add(setting);
|
||||
return setting;
|
||||
}
|
||||
|
||||
/** Returns all settings created in {@link XPackSettings}. */
|
||||
static List<Setting<?>> getAllSettings() {
|
||||
return Collections.unmodifiableList(ALL_SETTINGS);
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.rest.RestHandler;
|
|||
import org.elasticsearch.threadpool.ExecutorBuilder;
|
||||
import org.elasticsearch.threadpool.FixedExecutorBuilder;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.watcher.actions.WatcherActionModule;
|
||||
import org.elasticsearch.xpack.watcher.client.WatcherClientModule;
|
||||
import org.elasticsearch.xpack.watcher.condition.ConditionModule;
|
||||
|
@ -81,8 +82,6 @@ import static java.util.Collections.emptyList;
|
|||
|
||||
public class Watcher implements ActionPlugin {
|
||||
|
||||
public static final String NAME = "watcher";
|
||||
|
||||
public static final Setting<String> INDEX_WATCHER_VERSION_SETTING =
|
||||
new Setting<>("index.xpack.watcher.plugin.version", "", Function.identity(), Setting.Property.IndexScope);
|
||||
public static final Setting<String> INDEX_WATCHER_TEMPLATE_VERSION_SETTING =
|
||||
|
@ -105,7 +104,7 @@ public class Watcher implements ActionPlugin {
|
|||
public Watcher(Settings settings) {
|
||||
this.settings = settings;
|
||||
transportClient = "transport".equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey()));
|
||||
enabled = enabled(settings);
|
||||
this.enabled = XPackSettings.WATCHER_ENABLED.get(settings);
|
||||
validAutoCreateIndex(settings);
|
||||
}
|
||||
|
||||
|
@ -143,7 +142,6 @@ public class Watcher implements ActionPlugin {
|
|||
settings.add(ExecutionService.DEFAULT_THROTTLE_PERIOD_SETTING);
|
||||
settings.add(Setting.intSetting("xpack.watcher.execution.scroll.size", 0, Setting.Property.NodeScope));
|
||||
settings.add(Setting.intSetting("xpack.watcher.watch.scroll.size", 0, Setting.Property.NodeScope));
|
||||
settings.add(Setting.boolSetting(XPackPlugin.featureEnabledSetting(Watcher.NAME), true, Setting.Property.NodeScope));
|
||||
settings.add(ENCRYPT_SENSITIVE_DATA_SETTING);
|
||||
|
||||
settings.add(Setting.simpleString("xpack.watcher.internal.ops.search.default_timeout", Setting.Property.NodeScope));
|
||||
|
@ -161,7 +159,7 @@ public class Watcher implements ActionPlugin {
|
|||
}
|
||||
|
||||
public List<ExecutorBuilder<?>> getExecutorBuilders(final Settings settings) {
|
||||
if (XPackPlugin.featureEnabled(settings, Watcher.NAME, true)) {
|
||||
if (enabled) {
|
||||
final FixedExecutorBuilder builder =
|
||||
new FixedExecutorBuilder(
|
||||
settings,
|
||||
|
@ -205,10 +203,6 @@ public class Watcher implements ActionPlugin {
|
|||
RestHijackOperationAction.class);
|
||||
}
|
||||
|
||||
public static boolean enabled(Settings settings) {
|
||||
return XPackPlugin.featureEnabled(settings, NAME, true);
|
||||
}
|
||||
|
||||
static void validAutoCreateIndex(Settings settings) {
|
||||
String value = settings.get("action.auto_create_index");
|
||||
if (value == null) {
|
||||
|
|
|
@ -17,6 +17,8 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.xpack.XPackFeatureSet;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -30,13 +32,13 @@ public class WatcherFeatureSet implements XPackFeatureSet {
|
|||
@Inject
|
||||
public WatcherFeatureSet(Settings settings, @Nullable XPackLicenseState licenseState, @Nullable WatcherService watcherService) {
|
||||
this.watcherService = watcherService;
|
||||
this.enabled = Watcher.enabled(settings);
|
||||
this.enabled = XPackSettings.WATCHER_ENABLED.get(settings);
|
||||
this.licenseState = licenseState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return Watcher.NAME;
|
||||
return XPackPlugin.WATCHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,7 +71,7 @@ public class WatcherFeatureSet implements XPackFeatureSet {
|
|||
}
|
||||
|
||||
public Usage(boolean available, boolean enabled, Map<String, Object> stats) {
|
||||
super(Watcher.NAME, available, enabled);
|
||||
super(XPackPlugin.WATCHER, available, enabled);
|
||||
this.stats = stats;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.execution;
|
||||
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
public class InternalWatchExecutor implements WatchExecutor {
|
||||
|
||||
public static final String THREAD_POOL_NAME = Watcher.NAME;
|
||||
public static final String THREAD_POOL_NAME = XPackPlugin.WATCHER;
|
||||
|
||||
private final ThreadPool threadPool;
|
||||
|
||||
|
|
|
@ -5,22 +5,22 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.transport.actions;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.master.MasterNodeRequest;
|
||||
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.LicenseUtils;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.tasks.Task;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -43,7 +43,7 @@ public abstract class WatcherTransportAction<Request extends MasterNodeRequest<R
|
|||
if (licenseState.isWatcherAllowed()) {
|
||||
super.doExecute(task, request, listener);
|
||||
} else {
|
||||
listener.onFailure(LicenseUtils.newComplianceException(Watcher.NAME));
|
||||
listener.onFailure(LicenseUtils.newComplianceException(XPackPlugin.WATCHER));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,16 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher.transport.actions.get;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.elasticsearch.ElasticsearchException;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
|
@ -22,15 +24,13 @@ import org.elasticsearch.license.LicenseUtils;
|
|||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.watcher.WatcherService;
|
||||
import org.elasticsearch.xpack.watcher.support.xcontent.WatcherParams;
|
||||
import org.elasticsearch.xpack.watcher.transport.actions.WatcherTransportAction;
|
||||
import org.elasticsearch.xpack.watcher.watch.Watch;
|
||||
import org.elasticsearch.xpack.watcher.watch.WatchStore;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
|
||||
/**
|
||||
|
@ -64,7 +64,7 @@ public class TransportGetWatchAction extends WatcherTransportAction<GetWatchRequ
|
|||
protected void masterOperation(GetWatchRequest request, ClusterState state, ActionListener<GetWatchResponse> listener) throws
|
||||
ElasticsearchException {
|
||||
if (licenseState.isWatcherAllowed() == false) {
|
||||
listener.onFailure(LicenseUtils.newComplianceException(Watcher.NAME));
|
||||
listener.onFailure(LicenseUtils.newComplianceException(XPackPlugin.WATCHER));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,18 +10,18 @@ import org.elasticsearch.action.ActionListener;
|
|||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.cluster.ClusterState;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockException;
|
||||
import org.elasticsearch.cluster.block.ClusterBlockLevel;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.LicenseUtils;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.watcher.Watcher;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.watcher.WatcherService;
|
||||
import org.elasticsearch.xpack.watcher.transport.actions.WatcherTransportAction;
|
||||
import org.elasticsearch.xpack.watcher.watch.WatchStore;
|
||||
|
@ -56,7 +56,7 @@ public class TransportPutWatchAction extends WatcherTransportAction<PutWatchRequ
|
|||
protected void masterOperation(PutWatchRequest request, ClusterState state, ActionListener<PutWatchResponse> listener) throws
|
||||
ElasticsearchException {
|
||||
if (licenseState.isWatcherAllowed() == false) {
|
||||
listener.onFailure(LicenseUtils.newComplianceException(Watcher.NAME));
|
||||
listener.onFailure(LicenseUtils.newComplianceException(XPackPlugin.WATCHER));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.watcher;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodeInfo;
|
||||
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
|
||||
|
@ -13,20 +17,15 @@ import org.elasticsearch.common.network.NetworkModule;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.transport.Netty3Plugin;
|
||||
import org.elasticsearch.transport.Netty4Plugin;
|
||||
import org.elasticsearch.xpack.monitoring.Monitoring;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.xpack.security.Security;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.threadpool.ThreadPoolInfo;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.watcher.execution.InternalWatchExecutor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.elasticsearch.test.ESIntegTestCase.Scope.SUITE;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
|
@ -40,11 +39,11 @@ public class WatcherPluginDisableTests extends ESIntegTestCase {
|
|||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
.put(XPackPlugin.featureEnabledSetting(Watcher.NAME), false)
|
||||
.put(XPackSettings.WATCHER_ENABLED.getKey(), false)
|
||||
|
||||
// disable security because of query cache check and authentication/authorization
|
||||
.put(XPackPlugin.featureEnabledSetting(Security.NAME), false)
|
||||
.put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false)
|
||||
.put(XPackSettings.SECURITY_ENABLED.getKey(), false)
|
||||
.put(XPackSettings.MONITORING_ENABLED.getKey(), false)
|
||||
|
||||
.put(NetworkModule.HTTP_ENABLED.getKey(), true)
|
||||
.build();
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.elasticsearch.common.xcontent.XContentHelper;
|
|||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
import org.elasticsearch.xpack.XPackSettings;
|
||||
import org.elasticsearch.xpack.monitoring.Monitoring;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.script.MockMustacheScriptEngine;
|
||||
|
@ -137,7 +138,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase
|
|||
return Settings.builder()
|
||||
.put(super.nodeSettings(nodeOrdinal))
|
||||
//TODO: for now lets isolate watcher tests from monitoring (randomize this later)
|
||||
.put(XPackPlugin.featureEnabledSetting(Monitoring.NAME), false)
|
||||
.put(XPackSettings.MONITORING_ENABLED.getKey(), false)
|
||||
// we do this by default in core, but for watcher this isn't needed and only adds noise.
|
||||
.put("index.store.mock.check_index_on_close", false)
|
||||
.put("xpack.watcher.execution.scroll.size", randomIntBetween(1, 100))
|
||||
|
|
Loading…
Reference in New Issue