Ip Filtering: Change default rule to allow
In order to prevent confusion when starting up nodes (so they can join easily together) and adding some usability connections are not denied by default on the server side. Original commit: elastic/x-pack-elasticsearch@6ffe3a7df2
This commit is contained in:
parent
a47de7539c
commit
464bc0a752
|
@ -129,14 +129,14 @@ public class IPFilteringN2NAuthenticator extends AbstractComponent implements N2
|
|||
public boolean authenticate(@Nullable Principal peerPrincipal, InetAddress peerAddress, int peerPort) {
|
||||
for (IpFilterRule rule : rules) {
|
||||
if (rule.contains(peerAddress)) {
|
||||
boolean isAllowed = rule.isAllowRule();
|
||||
boolean isAllowed = rule.isAllowRule();
|
||||
logger.trace("Authentication rule matched for host [{}]: {}", peerAddress, isAllowed);
|
||||
return isAllowed;
|
||||
}
|
||||
}
|
||||
|
||||
logger.trace("Rejecting host {}", peerAddress);
|
||||
return false;
|
||||
logger.trace("Allowing host {}", peerAddress);
|
||||
return true;
|
||||
}
|
||||
|
||||
private class FileListener extends FileChangesListener {
|
||||
|
|
|
@ -71,10 +71,13 @@ public class IPFilteringN2NAuthenticatorTests extends ElasticsearchTestCase {
|
|||
|
||||
@Test
|
||||
public void testThatIpV6AddressesCanBeProcessed() throws Exception {
|
||||
writeConfigFile("allow: 2001:0db8:1234::/48\ndeny: 1234:0db8:85a3:0000:0000:8a2e:0370:7334");
|
||||
// you have to use the shortest possible notation in order to match, so
|
||||
// 1234:0db8:85a3:0000:0000:8a2e:0370:7334 becomes 1234:db8:85a3:0:0:8a2e:370:7334
|
||||
writeConfigFile("allow: 2001:0db8:1234::/48\ndeny: 1234:db8:85a3:0:0:8a2e:370:7334\ndeny: 4321:db8:1234::/48");
|
||||
|
||||
assertAddressIsAllowed("2001:0db8:1234:0000:0000:8a2e:0370:7334");
|
||||
assertAddressIsDenied("1234:0db8:85a3:0000:0000:8a2e:0370:7334");
|
||||
assertAddressIsDenied("4321:0db8:1234:0000:0000:8a2e:0370:7334");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -82,20 +85,20 @@ public class IPFilteringN2NAuthenticatorTests extends ElasticsearchTestCase {
|
|||
writeConfigFile("allow: localhost\ndeny: '*.google.com'");
|
||||
|
||||
assertAddressIsAllowed("127.0.0.1");
|
||||
assertAddressIsDenied("173.194.70.100");
|
||||
assertAddressIsDenied("8.8.8.8");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThatFileDeletionResultsInAllowingAll() throws Exception {
|
||||
writeConfigFile("allow: 127.0.0.1");
|
||||
writeConfigFile("deny: 127.0.0.1");
|
||||
|
||||
assertAddressIsAllowed("127.0.0.1");
|
||||
assertAddressIsDenied("127.0.0.1");
|
||||
|
||||
configFile.delete();
|
||||
assertThat(configFile.exists(), is(false));
|
||||
|
||||
sleep(250);
|
||||
assertAddressIsDenied("127.0.0.1");
|
||||
assertAddressIsAllowed("127.0.0.1");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -133,7 +136,7 @@ public class IPFilteringN2NAuthenticatorTests extends ElasticsearchTestCase {
|
|||
public void testThatEmptyFileDoesNotLeadIntoLoop() throws Exception {
|
||||
writeConfigFile("# \n\n");
|
||||
|
||||
assertAddressIsDenied("127.0.0.1");
|
||||
assertAddressIsAllowed("127.0.0.1");
|
||||
}
|
||||
|
||||
@Test(expected = ElasticsearchParseException.class)
|
||||
|
|
|
@ -39,13 +39,9 @@ public class IpFilteringIntegrationTests extends ShieldIntegrationTest {
|
|||
protected Settings nodeSettings(int nodeOrdinal) {
|
||||
ImmutableSettings.Builder builder = settingsBuilder().put(super.nodeSettings(nodeOrdinal));
|
||||
builder.put(InternalNode.HTTP_ENABLED, true);
|
||||
// either deny all or do not have a configuration file, as this denies by default
|
||||
if (getRandom().nextBoolean()) {
|
||||
File folder = newFolder();
|
||||
builder.put("shield.transport.n2n.ip_filter.file", writeFile(folder, "ip_filter.yml", CONFIG_IPFILTER_DENY_ALL));
|
||||
} else {
|
||||
builder.remove("shield.transport.n2n.ip_filter.file");
|
||||
}
|
||||
|
||||
File folder = newFolder();
|
||||
builder.put("shield.transport.n2n.ip_filter.file", writeFile(folder, "ip_filter.yml", CONFIG_IPFILTER_DENY_ALL));
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue