Package org.apache.solr.security.jwt
Class JWTAuthPlugin
java.lang.Object
org.apache.solr.security.AuthenticationPlugin
org.apache.solr.security.jwt.JWTAuthPlugin
- All Implemented Interfaces:
AutoCloseable,org.apache.solr.common.SpecProvider,SolrInfoBean,SolrMetricProducer,ConfigEditablePlugin
public class JWTAuthPlugin
extends AuthenticationPlugin
implements org.apache.solr.common.SpecProvider, ConfigEditablePlugin
Authentication plugin that finds logged in user by validating the signature of a JWT token
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classResponse for authentication attemptNested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoBean
SolrInfoBean.Category, SolrInfoBean.Group -
Field Summary
Fields 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 TypeMethodDescriptionprotected JWTAuthPlugin.JWTAuthenticationResponseauthenticate(String authorizationHeader) Testable authentication methodvoidclose()booleandoAuthenticate(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) Main authentication method that looks for correct JWT token in the Authorization headerOperate the commands on the latest conf and return a new conf object If there are errors in the commands , throw a SolrException.protected StringgetIssuerConfigByName(String name) Lookup issuer config by its nameorg.apache.solr.common.util.ValidatingJsonMapgetSpec()voidprotected booleaninterceptInternodeRequest(org.eclipse.jetty.client.Request request) protected voidRecord Issuer token URL as a system property so it can be picked up and sent to Admin UI as CSPMethods inherited from class org.apache.solr.security.AuthenticationPlugin
authenticate, closeRequest, getCategory, getDescription, getName, getSolrMetricsContext, initializeMetrics, wrapWithPrincipal, wrapWithPrincipal
-
Constructor Details
-
JWTAuthPlugin
public JWTAuthPlugin()Initialize plugin -
JWTAuthPlugin
-
-
Method Details
-
init
- Specified by:
initin classAuthenticationPlugin
-
registerTokenEndpointForCsp
protected void registerTokenEndpointForCsp()Record Issuer token URL as a system property so it can be picked up and sent to Admin UI as CSP -
doAuthenticate
public boolean doAuthenticate(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.servlet.FilterChain filterChain) throws Exception Main authentication method that looks for correct JWT token in the Authorization header- Specified by:
doAuthenticatein classAuthenticationPlugin- Throws:
Exception
-
authenticate
Testable authentication method- Parameters:
authorizationHeader- the http header "Authentication"- Returns:
- AuthenticationResponse object
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceSolrMetricProducer
-
getSpec
public org.apache.solr.common.util.ValidatingJsonMap getSpec()- Specified by:
getSpecin interfaceorg.apache.solr.common.SpecProvider
-
edit
public Map<String,Object> edit(Map<String, Object> latestConf, List<org.apache.solr.common.util.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. 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- Parameters:
latestConf- latest version of configcommands- the list of command operations to perform
-
generateAuthDataHeader
-
interceptInternodeRequest
protected boolean interceptInternodeRequest(org.eclipse.jetty.client.Request request) - Overrides:
interceptInternodeRequestin classAuthenticationPlugin
-
getIssuerConfigs
-
getIssuerConfigByName
Lookup issuer config by its name- Parameters:
name- name property of config- Returns:
- issuer config object or null if not found
-