mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-26 06:46:10 +00:00
Do not enforce TLS if discovery type is single-node (elastic/x-pack-elasticsearch#3245)
This commit adds a check for the discovery type so that the TLS join validator does not fail join requests when the discovery type is single-node. relates elastic/x-pack-elasticsearch#2828 Original commit: elastic/x-pack-elasticsearch@fdfdb76b0b
This commit is contained in:
parent
c7b100a8c3
commit
c6799de2a4
@ -49,6 +49,7 @@ import org.elasticsearch.common.xcontent.XContent;
|
|||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
|
import org.elasticsearch.discovery.DiscoveryModule;
|
||||||
import org.elasticsearch.env.Environment;
|
import org.elasticsearch.env.Environment;
|
||||||
import org.elasticsearch.http.HttpServerTransport;
|
import org.elasticsearch.http.HttpServerTransport;
|
||||||
import org.elasticsearch.index.IndexModule;
|
import org.elasticsearch.index.IndexModule;
|
||||||
@ -970,7 +971,8 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus
|
|||||||
@Override
|
@Override
|
||||||
public BiConsumer<DiscoveryNode, ClusterState> getJoinValidator() {
|
public BiConsumer<DiscoveryNode, ClusterState> getJoinValidator() {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
return new ValidateTLSOnJoin(XPackSettings.TRANSPORT_SSL_ENABLED.get(settings))
|
return new ValidateTLSOnJoin(XPackSettings.TRANSPORT_SSL_ENABLED.get(settings),
|
||||||
|
DiscoveryModule.DISCOVERY_TYPE_SETTING.get(settings))
|
||||||
.andThen(new ValidateUpgradedSecurityIndex());
|
.andThen(new ValidateUpgradedSecurityIndex());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -978,15 +980,18 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin, Clus
|
|||||||
|
|
||||||
static final class ValidateTLSOnJoin implements BiConsumer<DiscoveryNode, ClusterState> {
|
static final class ValidateTLSOnJoin implements BiConsumer<DiscoveryNode, ClusterState> {
|
||||||
private final boolean isTLSEnabled;
|
private final boolean isTLSEnabled;
|
||||||
|
private final String discoveryType;
|
||||||
|
|
||||||
ValidateTLSOnJoin(boolean isTLSEnabled) {
|
ValidateTLSOnJoin(boolean isTLSEnabled, String discoveryType) {
|
||||||
this.isTLSEnabled = isTLSEnabled;
|
this.isTLSEnabled = isTLSEnabled;
|
||||||
|
this.discoveryType = discoveryType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(DiscoveryNode node, ClusterState state) {
|
public void accept(DiscoveryNode node, ClusterState state) {
|
||||||
License license = LicenseService.getLicense(state.metaData());
|
License license = LicenseService.getLicense(state.metaData());
|
||||||
if (license != null && license.isProductionLicense() && isTLSEnabled == false) {
|
if (license != null && license.isProductionLicense() &&
|
||||||
|
isTLSEnabled == false && "single-node".equals(discoveryType) == false) {
|
||||||
throw new IllegalStateException("TLS setup is required for license type [" + license.operationMode().name() + "]");
|
throw new IllegalStateException("TLS setup is required for license type [" + license.operationMode().name() + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,14 +253,15 @@ public class SecurityTests extends ESTestCase {
|
|||||||
int numIters = randomIntBetween(1,10);
|
int numIters = randomIntBetween(1,10);
|
||||||
for (int i = 0; i < numIters; i++) {
|
for (int i = 0; i < numIters; i++) {
|
||||||
boolean tlsOn = randomBoolean();
|
boolean tlsOn = randomBoolean();
|
||||||
Security.ValidateTLSOnJoin validator = new Security.ValidateTLSOnJoin(tlsOn);
|
String discoveryType = randomFrom("single-node", "zen", randomAlphaOfLength(4));
|
||||||
|
Security.ValidateTLSOnJoin validator = new Security.ValidateTLSOnJoin(tlsOn, discoveryType);
|
||||||
MetaData.Builder builder = MetaData.builder();
|
MetaData.Builder builder = MetaData.builder();
|
||||||
License license = TestUtils.generateSignedLicense(TimeValue.timeValueHours(24));
|
License license = TestUtils.generateSignedLicense(TimeValue.timeValueHours(24));
|
||||||
TestUtils.putLicense(builder, license);
|
TestUtils.putLicense(builder, license);
|
||||||
ClusterState state = ClusterState.builder(ClusterName.DEFAULT).metaData(builder.build()).build();
|
ClusterState state = ClusterState.builder(ClusterName.DEFAULT).metaData(builder.build()).build();
|
||||||
EnumSet<License.OperationMode> productionModes = EnumSet.of(License.OperationMode.GOLD, License.OperationMode.PLATINUM,
|
EnumSet<License.OperationMode> productionModes = EnumSet.of(License.OperationMode.GOLD, License.OperationMode.PLATINUM,
|
||||||
License.OperationMode.STANDARD);
|
License.OperationMode.STANDARD);
|
||||||
if (productionModes.contains(license.operationMode()) && tlsOn == false) {
|
if (productionModes.contains(license.operationMode()) && tlsOn == false && "single-node".equals(discoveryType) == false) {
|
||||||
IllegalStateException ise = expectThrows(IllegalStateException.class, () -> validator.accept(node, state));
|
IllegalStateException ise = expectThrows(IllegalStateException.class, () -> validator.accept(node, state));
|
||||||
assertEquals("TLS setup is required for license type [" + license.operationMode().name() + "]", ise.getMessage());
|
assertEquals("TLS setup is required for license type [" + license.operationMode().name() + "]", ise.getMessage());
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user