SOLR-7274: Stop forwarding Authorization, Host, and Accept headers for SPNego to work. Also fixed an exception forwarding from SDF and reconfigure SDF's httpClient after authentication has been initialized.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1680931 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Anshum Gupta 2015-05-21 17:21:44 +00:00
parent 10dd568c8e
commit 38876c2209
4 changed files with 18 additions and 8 deletions

View File

@ -194,9 +194,7 @@ public class HttpShardHandlerFactory extends ShardHandlerFactory implements org.
*/
public void reconfigureHttpClient(HttpClientConfigurer configurer) {
log.info("Reconfiguring the default client with: " + configurer);
synchronized (this.defaultClient) {
configurer.configure((DefaultHttpClient)this.defaultClient, getClientParams());
}
configurer.configure((DefaultHttpClient)this.defaultClient, getClientParams());
}
protected ThreadPoolExecutor getThreadPoolExecutor(){

View File

@ -511,7 +511,11 @@ public class HttpSolrCall {
for (Enumeration<String> e = req.getHeaderNames(); e.hasMoreElements(); ) {
String headerName = e.nextElement();
method.addHeader(headerName, req.getHeader(headerName));
if (!"host".equalsIgnoreCase(headerName)
&& !"authorization".equalsIgnoreCase(headerName)
&& !"accept".equalsIgnoreCase(headerName)) {
method.addHeader(headerName, req.getHeader(headerName));
}
}
// These headers not supported for HttpEntityEnclosingRequests
if (method instanceof HttpEntityEnclosingRequest) {

View File

@ -24,6 +24,7 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
@ -36,6 +37,8 @@ import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.solr.client.solrj.impl.HttpClientConfigurer;
import org.apache.solr.client.solrj.impl.HttpClientUtil;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
@ -106,6 +109,13 @@ public class SolrDispatchFilter extends BaseSolrFilter {
this.cores = createCoreContainer(solrHome, extraProperties);
if (this.cores.getAuthenticationPlugin() != null) {
HttpClientConfigurer configurer = this.cores.getAuthenticationPlugin().getDefaultConfigurer();
if (configurer != null) {
configurer.configure((DefaultHttpClient)httpClient, new ModifiableSolrParams());
}
}
log.info("user.dir=" + System.getProperty("user.dir"));
}
catch( Throwable t ) {
@ -248,7 +258,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
});
} catch (Exception e) {
e.printStackTrace();
throw new SolrException(ErrorCode.SERVER_ERROR, "Error during request authentication, "+e);
throw new SolrException(ErrorCode.SERVER_ERROR, "Error during request authentication, ", e);
}
}
// failed authentication?

View File

@ -90,9 +90,7 @@ public class UpdateShardHandler {
public void reconfigureHttpClient(HttpClientConfigurer configurer) {
log.info("Reconfiguring the default client with: " + configurer);
synchronized (client) {
configurer.configure((DefaultHttpClient)client, getClientParams());
}
configurer.configure((DefaultHttpClient)client, getClientParams());
}
public ClientConnectionManager getConnectionManager() {