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,10 +194,8 @@ public class HttpShardHandlerFactory extends ShardHandlerFactory implements org.
*/ */
public void reconfigureHttpClient(HttpClientConfigurer configurer) { public void reconfigureHttpClient(HttpClientConfigurer configurer) {
log.info("Reconfiguring the default client with: " + 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(){ protected ThreadPoolExecutor getThreadPoolExecutor(){
return this.commExecutor; return this.commExecutor;

View File

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

View File

@ -24,6 +24,7 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -36,6 +37,8 @@ import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.http.impl.client.CloseableHttpClient; 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.client.solrj.impl.HttpClientUtil;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
@ -106,6 +109,13 @@ public class SolrDispatchFilter extends BaseSolrFilter {
this.cores = createCoreContainer(solrHome, extraProperties); 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")); log.info("user.dir=" + System.getProperty("user.dir"));
} }
catch( Throwable t ) { catch( Throwable t ) {
@ -248,7 +258,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {
}); });
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); 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? // failed authentication?

View File

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