Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.SecureSettings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -786,11 +787,22 @@ private static void addTribeSettings(Settings settings, Settings.Builder setting
}

// we passed all the checks now we need to copy in all of the x-pack security settings
settings.keySet().forEach(k -> {
SecureSettings secureSettings = Settings.builder().put(settings).getSecureSettings(); // hack to get at secure settings...
Set<String> secureSettingKeys = secureSettings == null ? Collections.emptySet() : secureSettings.getSettingNames();
List<String> invalidSettings = new ArrayList<>();
for (String k : settings.keySet()) {
if (k.startsWith("xpack.security.")) {
settingsBuilder.copy(tribePrefix + k, k, settings);
if (secureSettingKeys.contains(k)) {
invalidSettings.add(k);
} else {
settingsBuilder.copy(tribePrefix + k, k, settings);
}
}
});
}
if (invalidSettings.isEmpty() == false) {
throw new IllegalArgumentException("Secure settings " + invalidSettings.toString() +
" cannot be used with tribe client node");
}
}

Map<String, Settings> realmsSettings = settings.getGroups(SecurityField.setting("authc.realms"), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,22 @@ public void testTribeSettingNames() throws Exception {
s, anyOf(startsWith("tribe.blocks"), startsWith("tribe.name"), startsWith("tribe.on_conflict"))));
}

public void testNoTribeSecureSettings() throws Exception {
MockSecureSettings secureSettings = new MockSecureSettings();
Path home = createTempDir();
secureSettings.setString("xpack.security.http.ssl.keystore.secure_password", "dummypass");
secureSettings.setString("xpack.security.authc.token.passphrase", "dummypass");
Settings settings = Settings.builder().setSecureSettings(secureSettings)
.put("path.home", home)
.put("tribe.t1.cluster.name", "foo")
.put("xpack.security.enabled", true).build();
Security security = new Security(settings, home.resolve("config"));
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, security::additionalSettings);
// can't rely on order of the strings printed in the exception message
assertThat(e.getMessage(), containsString("xpack.security.http.ssl.keystore.secure_password"));
assertThat(e.getMessage(), containsString("xpack.security.authc.token.passphrase"));
}

private void assertTribeNodeHasAllIndices() throws Exception {
assertBusy(() -> {
Set<String> indices = new HashSet<>();
Expand Down