Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOLR-15154: Let Http2SolrClient pass Basic Auth credentials to all requests #2445

Merged
merged 4 commits into from
Mar 5, 2021

Conversation

tflobbe
Copy link
Member

@tflobbe tflobbe commented Mar 3, 2021

Credentials can now be set explicitly at the client level, or can be read from System properties like in the previous version of the client when using PreemptiveBasicAuthClientBuilderFactory. Other implementations of HttpClientBuilderFactory can now also be used.

This test also adds a small refactor to PreemptiveBasicAuthClientBuilderFactory for better testing.

…quests

Credentials can now be set explicitly at the client level, or can be read from System properties like in the previous version of the client when using PreemptiveBasicAuthClientBuilderFactory. Other implementations of HttpClientBuilderFactory can now also be used.
Copy link
Contributor

@anshumg anshumg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great.

Some minor suggestions.

private void httpClientBuilderSetup(Http2SolrClient client) {
String factoryClassName = System.getProperty(HttpClientUtil.SYS_PROP_HTTP_CLIENT_BUILDER_FACTORY);
if (factoryClassName != null) {
log.debug ("Using Builder Factory: {}", factoryClassName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using HTTP Client Builder Factory?

public Builder withBasicAuthCredentials(String user, String pass) {
if (user != null || pass != null) {
if (user == null || pass == null) {
throw new IllegalStateException("Invalid Authentication credentials. Either both or none must be provided");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both -> both user(name) and password ?

unIgnoreException("Error from server");
assertTrue(DebugServlet.headers.size() > 0);
String authorizationHeader = DebugServlet.headers.get("authorization");
assertNotNull("Expecting authorization header but got: " + DebugServlet.headers, authorizationHeader);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to reframe the test failure message as No authorization information in the header found. Header :
Feel free to ignore it, but as you were printing the entire header, I thought specifying that made it more obvious.

@tflobbe tflobbe merged commit fe33a43 into apache:master Mar 5, 2021
@tflobbe tflobbe deleted the SOLR-15154-2 branch March 5, 2021 18:51
tflobbe added a commit to tflobbe/lucene-solr-1 that referenced this pull request Mar 5, 2021
…quests (apache#2445)

Credentials can now be set explicitly at the client level, or can be read from System properties like in the previous version of the client when using PreemptiveBasicAuthClientBuilderFactory. Other implementations of HttpClientBuilderFactory can now also be used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants