Package org.apache.solr.security
Class BasicAuthPlugin
java.lang.Object
org.apache.solr.security.AuthenticationPlugin
org.apache.solr.security.BasicAuthPlugin
- All Implemented Interfaces:
AutoCloseable,org.apache.solr.common.SpecProvider,SolrInfoBean,SolrMetricProducer,ConfigEditablePlugin
public class BasicAuthPlugin
extends AuthenticationPlugin
implements ConfigEditablePlugin, org.apache.solr.common.SpecProvider
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoBean
SolrInfoBean.Category, SolrInfoBean.Group -
Field Summary
FieldsFields inherited from class org.apache.solr.security.AuthenticationPlugin
AUTHENTICATION_PLUGIN_PROP, HTTP_HEADER_X_SOLR_AUTHDATA, numAuthenticated, numErrors, numMissingCredentials, numPassThrough, numWrongCredentials, requests, requestTimes, solrMetricsContextFields inherited from interface org.apache.solr.metrics.SolrMetricProducer
CATEGORY_ATTR, HANDLER_ATTR, NAME_ATTR, OPERATION_ATTR, PLUGIN_NAME_ATTR, RESULT_ATTR, TYPE_ATTR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanauthenticate(String username, String pwd) voidclose()Implementations should always callSolrMetricProducer.super.close()to ensure that metrics with the same life-cycle as this component are properly unregistered.voidCleanup any per request databooleandoAuthenticate(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) This method attempts to authenticate the request.Operate the commands on the latest conf and return a new conf object If there are errors in the commands , throw a SolrException.protected BasicAuthPlugin.AuthenticationProvidergetAuthenticationProvider(Map<String, Object> pluginConfig) booleanorg.apache.solr.common.util.ValidatingJsonMapgetSpec()voidThis is called upon loading up of a plugin, used for setting it up.protected booleaninterceptInternodeRequest(org.eclipse.jetty.client.Request request) Override this method to intercept internode requests.Methods inherited from class org.apache.solr.security.AuthenticationPlugin
authenticate, getCategory, getDescription, getName, getSolrMetricsContext, initializeMetrics, wrapWithPrincipal, wrapWithPrincipal
-
Field Details
-
PROPERTY_BLOCK_UNKNOWN
- See Also:
-
PROPERTY_REALM
- See Also:
-
FORWARD_CREDENTIALS
- See Also:
-
-
Constructor Details
-
BasicAuthPlugin
public BasicAuthPlugin()
-
-
Method Details
-
authenticate
-
init
Description copied from class:AuthenticationPluginThis is called upon loading up of a plugin, used for setting it up.- Specified by:
initin classAuthenticationPlugin- Parameters:
pluginConfig- Config parameters, possibly from a ZK source
-
edit
public Map<String,Object> edit(Map<String, Object> latestConf, List<org.apache.solr.common.util.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 interfaceConfigEditablePlugin
-
getAuthenticationProvider
protected BasicAuthPlugin.AuthenticationProvider getAuthenticationProvider(Map<String, Object> pluginConfig) -
doAuthenticate
public boolean doAuthenticate(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) throws Exception Description 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 classAuthenticationPlugin- Parameters:
request- the http requestresponse- the http responsefilterChain- 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
-
close
Description 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 interfaceAutoCloseable- Specified by:
closein interfaceSolrMetricProducer- Throws:
IOException
-
closeRequest
public void closeRequest()Description copied from class:AuthenticationPluginCleanup any per request data- Overrides:
closeRequestin classAuthenticationPlugin
-
interceptInternodeRequest
protected boolean interceptInternodeRequest(org.eclipse.jetty.client.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 classAuthenticationPlugin- 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
-
getSpec
public org.apache.solr.common.util.ValidatingJsonMap getSpec()- Specified by:
getSpecin interfaceorg.apache.solr.common.SpecProvider
-
getBlockUnknown
public boolean getBlockUnknown()
-