Skip to content

Commit

Permalink
SOLR-15155: Document how to set credentials in CloudHttp2SolrClient (#51
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tflobbe committed Apr 20, 2021
1 parent 18d94a5 commit 2c0d67e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions solr/solr-ref-guide/src/basic-authentication-plugin.adoc
Expand Up @@ -223,6 +223,16 @@ Http2SolrClient client = new Http2SolrClient.Builder(solrUrl)
QueryResponse rsp = req.process(client);
----

CloudHttp2SolrClient supports receiving an `Http2SolrClient.Builder` instance for creating its internal client, so to set the credentials at the client level you could use a code like:

[source,java]
----
Http2SolrClient.Builder http2ClientBuilder = Http2SolrClient.Builder().withBasicAuthCredentials(userName, password);
CloudHttp2SolrClient client = new CloudHttp2SolrClient.Builder(zkHostList, chroot)
.withInternalClientBuilder(http2ClientBuilder).build();
QueryResponse rsp = req.process(client);
----

=== Global (JVM) Basic Auth Credentials
Alternatively, users can use SolrJ's `PreemptiveBasicAuthClientBuilderFactory` to add basic authentication credentials to _all_ requests automatically.
To enable this feature, users should set the following system property `-Dsolr.httpclient.builder.factory=org.apache.solr.client.solrj.impl.PreemptiveBasicAuthClientBuilderFactory`.
Expand Down

0 comments on commit 2c0d67e

Please sign in to comment.