You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by tf...@apache.org on 2021/04/20 04:15:53 UTC
[solr] branch main updated: SOLR-15155: Document how to set
credentials in CloudHttp2SolrClient (#51)
This is an automated email from the ASF dual-hosted git repository.
tflobbe pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 72a9948 SOLR-15155: Document how to set credentials in CloudHttp2SolrClient (#51)
72a9948 is described below
commit 72a99483c93cbeed4b09ed6cbb94ad3111afafe4
Author: Tomas Fernandez Lobbe <tf...@apache.org>
AuthorDate: Mon Apr 19 21:15:47 2021 -0700
SOLR-15155: Document how to set credentials in CloudHttp2SolrClient (#51)
---
solr/solr-ref-guide/src/basic-authentication-plugin.adoc | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/solr/solr-ref-guide/src/basic-authentication-plugin.adoc b/solr/solr-ref-guide/src/basic-authentication-plugin.adoc
index 3e0fef1..48e6485 100644
--- a/solr/solr-ref-guide/src/basic-authentication-plugin.adoc
+++ b/solr/solr-ref-guide/src/basic-authentication-plugin.adoc
@@ -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`.