mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-05-31 09:12:11 +00:00
DATAES-598: Add Elasticsearch authentication code example to readme.
Original PR: #289
This commit is contained in:
parent
6a3042c437
commit
7ea0a43162
16
README.adoc
16
README.adoc
@ -243,6 +243,22 @@ public class Config {
|
||||
}
|
||||
}
|
||||
|
||||
// If necessary, a BASIC_AUTH (user and password) header can be set with:
|
||||
|
||||
@Configuration
|
||||
public class ConfigWithAuthentication {
|
||||
|
||||
@Bean
|
||||
public ReactiveElasticsearchClient reactiveElasticsearchClient() {
|
||||
HttpHeaders defaultHeaders = new HttpHeaders();
|
||||
defaultHeaders.setBasicAuth(USER_NAME, USER_PASS);
|
||||
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
|
||||
.connectedTo("localhost:9200", "localhost:9291")
|
||||
.withDefaultHeaders(defaultHeaders).build();
|
||||
return ReactiveRestClients.create(clientConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
// ...
|
||||
|
||||
Mono<IndexResponse> response = client.index(request ->
|
||||
|
Loading…
x
Reference in New Issue
Block a user