Package org.apache.solr.security
Class AuthenticationPlugin
java.lang.Object
org.apache.solr.security.AuthenticationPlugin
- All Implemented Interfaces:
AutoCloseable,SolrInfoBean,SolrMetricProducer
- Direct Known Subclasses:
BasicAuthPlugin,CertAuthPlugin,MultiAuthPlugin,PKIAuthenticationPlugin
- 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.SolrInfoBean
SolrInfoBean.Category, SolrInfoBean.Group -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringprotected AttributedLongCounterprotected AttributedLongCounterprotected AttributedLongCounterprotected AttributedLongCounterprotected AttributedLongCounterprotected AttributedLongCounterprotected AttributedLongTimerprotected 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 TypeMethodDescriptionfinal booleanauthenticate(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) This method is called by SolrDispatchFilter in order to initiate authentication.voidCleanup any per request dataabstract booleandoAuthenticate(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) This method attempts to authenticate the request.Category of this componentSimple one or two line descriptiongetName()Simple common usage name, e.g.Implementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, Attributes)to ensure proper cleanup of metrics at the end of the life-cycle of this component.abstract voidThis is called upon loading up of a plugin, used for setting it up.voidinitializeMetrics(SolrMetricsContext parentContext, io.opentelemetry.api.common.Attributes attributes) Implementation should initialize all metrics to aSolrMetricsContextRegistry/MeterProvider withAttributesas the common set of attributes that will be attached to every metric that is initialized for that class/componentprotected booleaninterceptInternodeRequest(org.eclipse.jetty.client.Request request) Override this method to intercept internode requests.protected jakarta.servlet.http.HttpServletRequestwrapWithPrincipal(jakarta.servlet.http.HttpServletRequest request, Principal principal) protected jakarta.servlet.http.HttpServletRequestwrapWithPrincipal(jakarta.servlet.http.HttpServletRequest request, Principal principal, String username) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.solr.metrics.SolrMetricProducer
close
-
Field Details
-
AUTHENTICATION_PLUGIN_PROP
- See Also:
-
HTTP_HEADER_X_SOLR_AUTHDATA
- See Also:
-
solrMetricsContext
-
numErrors
-
requests
-
requestTimes
-
numAuthenticated
-
numPassThrough
-
numWrongCredentials
-
numMissingCredentials
-
-
Constructor Details
-
AuthenticationPlugin
public AuthenticationPlugin()
-
-
Method Details
-
init
This is called upon loading up of a plugin, used for setting it up.- Parameters:
pluginConfig- Config parameters, possibly from a ZK source
-
doAuthenticate
public abstract boolean doAuthenticate(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) throws Exception This 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.- 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
-
authenticate
public final boolean authenticate(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) throws Exception This method is called by SolrDispatchFilter in order to initiate authentication. It does some standard metrics counting.- Throws:
Exception
-
wrapWithPrincipal
protected jakarta.servlet.http.HttpServletRequest wrapWithPrincipal(jakarta.servlet.http.HttpServletRequest request, Principal principal) -
wrapWithPrincipal
-
interceptInternodeRequest
protected boolean interceptInternodeRequest(org.eclipse.jetty.client.Request request) Override 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.- 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
-
closeRequest
public void closeRequest()Cleanup any per request data -
getSolrMetricsContext
Description copied from interface:SolrMetricProducerImplementations should return the context used inSolrMetricProducer.initializeMetrics(SolrMetricsContext, Attributes)to ensure proper cleanup of metrics at the end of the life-cycle of this component. This should be the child context if one was created, or null if the parent context was used.- Specified by:
getSolrMetricsContextin interfaceSolrMetricProducer
-
initializeMetrics
public void initializeMetrics(SolrMetricsContext parentContext, io.opentelemetry.api.common.Attributes attributes) Description copied from interface:SolrMetricProducerImplementation should initialize all metrics to aSolrMetricsContextRegistry/MeterProvider withAttributesas the common set of attributes that will be attached to every metric that is initialized for that class/component- Specified by:
initializeMetricsin interfaceSolrMetricProducer- Parameters:
parentContext- The registry that the component will initialize metrics toattributes- Base set of attributes that will be bound to all metrics for that component
-
getName
Description copied from interface:SolrInfoBeanSimple common usage name, e.g. BasicQueryHandler, or fully qualified class name.- Specified by:
getNamein interfaceSolrInfoBean
-
getDescription
Description copied from interface:SolrInfoBeanSimple one or two line description- Specified by:
getDescriptionin interfaceSolrInfoBean
-
getCategory
Description copied from interface:SolrInfoBeanCategory of this component- Specified by:
getCategoryin interfaceSolrInfoBean
-