Skip to content

Commit a7974e7

Browse files
committed
log warning if both secure password and deprecated password are supplied
1 parent 9e3a591 commit a7974e7

File tree

1 file changed

+11
-3
lines changed
  • x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http

1 file changed

+11
-3
lines changed

x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java

+11-3
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,18 @@ public static List<String> loadSettings(Settings settings) {
730730
private static CredentialsProvider createCredentialsProvider(final Config config) {
731731
final String username = AUTH_USERNAME_SETTING.getConcreteSettingForNamespace(config.name()).get(config.settings());
732732

733+
final String deprecatedPassword = AUTH_PASSWORD_SETTING.getConcreteSettingForNamespace(config.name()).get(config.settings());
733734
final SecureString securePassword = SECURE_AUTH_PASSWORDS.get(config.name());
734-
final String password = securePassword == null
735-
? AUTH_PASSWORD_SETTING.getConcreteSettingForNamespace(config.name()).get(config.settings())
736-
: securePassword.toString();
735+
final String password;
736+
if (securePassword != null) {
737+
password = securePassword.toString();
738+
if (Strings.isNullOrEmpty(deprecatedPassword) == false) {
739+
logger.warn("exporter [{}] specified both auth.secure_password and auth.password. using auth.secure_password and " +
740+
"ignoring auth.password", config.name());
741+
}
742+
} else {
743+
password = deprecatedPassword;
744+
}
737745

738746
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
739747
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));

0 commit comments

Comments
 (0)