Skip to content

Commit f7d52d0

Browse files
committed
Prevent unsafe use of HTTP with basic or API key authentication
1 parent 15c3f56 commit f7d52d0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

extensions/elasticsearch-rest-client/runtime/src/main/java/io/quarkus/elasticsearch/restclient/lowlevel/runtime/RestClientBuilderHelper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ private static void applyAuthentication(HttpAsyncClientBuilder httpClientBuilder
117117
"authentication OR only a valid API key for ApiKey authentication. Both methods are currently " +
118118
"enabled.");
119119
}
120+
if (!"https".equalsIgnoreCase(config.protocol()) && (hasBasic || hasApiKey)) {
121+
LOG.warn("Transmitting authentication information over HTTP is unsafe as it implies sending sensitive " +
122+
"information as plain text over an unencrypted channel. Use the HTTPS protocol instead.");
123+
}
120124
if (hasBasic) {
121-
if (!"https".equalsIgnoreCase(config.protocol())) {
122-
LOG.warn("Using Basic authentication in HTTP implies sending plain text passwords over the wire, " +
123-
"use the HTTPS protocol instead.");
124-
}
125125
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
126126
credentialsProvider.setCredentials(AuthScope.ANY,
127127
new UsernamePasswordCredentials(config.username().get(), config.password().orElse(null)));

0 commit comments

Comments
 (0)