Package org.apache.solr.security
Class MultiAuthPlugin
- java.lang.Object
- 
- org.apache.solr.security.AuthenticationPlugin
- 
- org.apache.solr.security.MultiAuthPlugin
 
 
- 
- All Implemented Interfaces:
- AutoCloseable,- SpecProvider,- SolrInfoBean,- SolrMetricProducer,- ConfigEditablePlugin
 
 public class MultiAuthPlugin extends AuthenticationPlugin implements ConfigEditablePlugin, SpecProvider Authentication plugin that supports multiple Authorization schemes, such as Bearer and Basic. The impl simply delegates to one of Solr's other AuthenticationPlugins, such as the BasicAuthPlugin or JWTAuthPlugin.- WARNING: This API is experimental and might change in incompatible ways in the next release.
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoBeanSolrInfoBean.Category, SolrInfoBean.Group
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static StringAUTHORIZATION_HEADERstatic StringPROPERTY_SCHEMEstatic StringPROPERTY_SCHEMES- 
Fields inherited from class org.apache.solr.security.AuthenticationPluginAUTHENTICATION_PLUGIN_PROP, HTTP_HEADER_X_SOLR_AUTHDATA, numAuthenticated, numErrors, numMissingCredentials, numPassThrough, numWrongCredentials, requests, requestTimes, solrMetricsContext, totalTime
 
- 
 - 
Constructor SummaryConstructors Constructor Description MultiAuthPlugin(CoreContainer cc)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Implementations should always callSolrMetricProducer.super.close()to ensure that metrics with the same life-cycle as this component are properly unregistered.voidcloseRequest()Cleanup any per request databooleandoAuthenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain)This method attempts to authenticate the request.Map<String,Object>edit(Map<String,Object> latestConf, List<CommandOperation> commands)Operate the commands on the latest conf and return a new conf object If there are errors in the commands , throw a SolrException.ValidatingJsonMapgetSpec()voidinit(Map<String,Object> pluginConfig)This is called upon loading up of a plugin, used for setting it up.voidinitializeMetrics(SolrMetricsContext parentContext, String scope)Initialize metrics specific to this producer.protected voidinitPluginForScheme(Map<String,Object> schemeMap)protected booleaninterceptInternodeRequest(org.apache.http.HttpRequest httpRequest, org.apache.http.protocol.HttpContext httpContext)Override this method to intercept internode requests.protected booleaninterceptInternodeRequest(org.eclipse.jetty.client.api.Request request)Override this method to intercept internode requests.- 
Methods inherited from class org.apache.solr.security.AuthenticationPluginauthenticate, getCategory, getDescription, getName, getSolrMetricsContext, wrapWithPrincipal, wrapWithPrincipal
 
- 
 
- 
- 
- 
Field Detail- 
PROPERTY_SCHEMESpublic static final String PROPERTY_SCHEMES - See Also:
- Constant Field Values
 
 - 
PROPERTY_SCHEMEpublic static final String PROPERTY_SCHEME - See Also:
- Constant Field Values
 
 - 
AUTHORIZATION_HEADERpublic static final String AUTHORIZATION_HEADER - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
MultiAuthPluginpublic MultiAuthPlugin(CoreContainer cc) 
 
- 
 - 
Method Detail- 
initpublic void init(Map<String,Object> pluginConfig) Description copied from class:AuthenticationPluginThis is called upon loading up of a plugin, used for setting it up.- Specified by:
- initin class- AuthenticationPlugin
- Parameters:
- pluginConfig- Config parameters, possibly from a ZK source
 
 - 
initializeMetricspublic void initializeMetrics(SolrMetricsContext parentContext, String scope) Description copied from interface:SolrMetricProducerInitialize metrics specific to this producer.- Specified by:
- initializeMetricsin interface- SolrMetricProducer
- Overrides:
- initializeMetricsin class- AuthenticationPlugin
- Parameters:
- parentContext- parent metrics context. If this component has the same life-cycle as the parent it can simply use the parent context, otherwise it should obtain a child context using- SolrMetricsContext.getChildContext(Object)passing- thisas the child object.
- scope- component scope
 
 - 
doAuthenticatepublic boolean doAuthenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain) throws ExceptionDescription copied from class:AuthenticationPluginThis method attempts to authenticate the request. Upon a successful authentication, this must call the next filter in the filter chain and set the user principal of the request, or else, upon an error or an authentication failure, throw an exception.- Specified by:
- doAuthenticatein class- AuthenticationPlugin
- Parameters:
- request- the http request
- response- the http response
- filterChain- the servlet filter chain
- Returns:
- false if the request not be processed by Solr (not continue), i.e. the response and status code have already been sent.
- Throws:
- Exception- any exception thrown during the authentication, e.g. PrivilegedActionException
 
 - 
closepublic void close() throws IOExceptionDescription copied from interface:SolrMetricProducerImplementations should always callSolrMetricProducer.super.close()to ensure that metrics with the same life-cycle as this component are properly unregistered. This prevents obscure memory leaks.from: https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html While this interface method is declared to throw Exception, implementers are strongly encouraged to declare concrete implementations of the close method to throw more specific exceptions, or to throw no exception at all if the close operation cannot fail. - Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- SolrMetricProducer
- Throws:
- IOException
 
 - 
closeRequestpublic void closeRequest() Description copied from class:AuthenticationPluginCleanup any per request data- Overrides:
- closeRequestin class- AuthenticationPlugin
 
 - 
interceptInternodeRequestprotected boolean interceptInternodeRequest(org.apache.http.HttpRequest httpRequest, org.apache.http.protocol.HttpContext httpContext)Description copied from class:AuthenticationPluginOverride this method to intercept internode requests. This allows your authentication plugin to decide on per-request basis whether it should handle inter-node requests or delegate toPKIAuthenticationPlugin. Return true to indicate that your plugin did handle the request, or false to signal that PKI plugin should handle it. This method will be called byPKIAuthenticationPlugin's interceptor.If not overridden, this method will return true for plugins implementing HttpClientBuilderPlugin. This method can be overridden by subclasses e.g. to set HTTP headers, even if you don't use a clientBuilder.- Overrides:
- interceptInternodeRequestin class- AuthenticationPlugin
- Parameters:
- httpRequest- the httpRequest that is about to be sent to another internal Solr node
- httpContext- the context of that request.
- Returns:
- true if this plugin handled authentication for the request, else false
 
 - 
interceptInternodeRequestprotected boolean interceptInternodeRequest(org.eclipse.jetty.client.api.Request request) Description copied from class:AuthenticationPluginOverride this method to intercept internode requests. This allows your authentication plugin to decide on per-request basis whether it should handle inter-node requests or delegate toPKIAuthenticationPlugin. Return true to indicate that your plugin did handle the request, or false to signal that PKI plugin should handle it. This method will be called byPKIAuthenticationPlugin's interceptor.If not overridden, this method will return true for plugins implementing HttpClientBuilderPlugin. This method can be overridden by subclasses e.g. to set HTTP headers, even if you don't use a clientBuilder.- Overrides:
- interceptInternodeRequestin class- AuthenticationPlugin
- Parameters:
- request- the httpRequest that is about to be sent to another internal Solr node
- Returns:
- true if this plugin handled authentication for the request, else false
 
 - 
getSpecpublic ValidatingJsonMap getSpec() - Specified by:
- getSpecin interface- SpecProvider
 
 - 
editpublic Map<String,Object> edit(Map<String,Object> latestConf, List<CommandOperation> commands) Description copied from interface:ConfigEditablePluginOperate the commands on the latest conf and return a new conf object If there are errors in the commands , throw a SolrException. return a null if no changes are to be made as a result of this edit. It is the responsibility of the implementation to ensure that the returned config is valid . The framework does no validation of the data- Specified by:
- editin interface- ConfigEditablePlugin
 
 
- 
 
-