Class ConfigAwarePreAuthenticationFilter

java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter
org.craftercms.engine.util.spring.security.ConfigAwarePreAuthenticationFilter
All Implemented Interfaces:
jakarta.servlet.Filter, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationEventPublisherAware, org.springframework.context.EnvironmentAware, org.springframework.core.env.EnvironmentCapable, org.springframework.web.context.ServletContextAware
Direct Known Subclasses:
TargetingPreAuthenticatedFilter

public abstract class ConfigAwarePreAuthenticationFilter extends org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter
Extension of AbstractPreAuthenticatedProcessingFilter that uses site config to enable processing:
  • If alwaysEnabled is true the filter will be executed, even if there is no site configuration available
  • If the site configuration contains the enabledConfigKey with a value of true the filter will be executed
Additionally, if the existing principal is an instance of any class other than supportedPrincipalClass the filter will not be executed
Since:
3.1.5
Author:
joseross
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected String
     
    protected Class<? extends org.springframework.security.core.userdetails.UserDetails>
     

    Fields inherited from class org.springframework.web.filter.GenericFilterBean

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain)
     
    protected Object
    getPreAuthenticatedCredentials(jakarta.servlet.http.HttpServletRequest request)
     
    boolean
     
    protected boolean
    principalChanged(jakarta.servlet.http.HttpServletRequest request, org.springframework.security.core.Authentication currentAuthentication)
     
    void
    setAlwaysEnabled(boolean alwaysEnabled)
     
    void
    setSupportedPrincipalClass(Class<? extends org.springframework.security.core.userdetails.UserDetails> supportedPrincipalClass)
     

    Methods inherited from class org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter

    afterPropertiesSet, getAuthenticationDetailsSource, getPreAuthenticatedPrincipal, setApplicationEventPublisher, setAuthenticationDetailsSource, setAuthenticationFailureHandler, setAuthenticationManager, setAuthenticationSuccessHandler, setCheckForPrincipalChanges, setContinueFilterChainOnUnsuccessfulAuthentication, setInvalidateSessionOnPrincipalChange, setRequiresAuthenticationRequestMatcher, setSecurityContextHolderStrategy, setSecurityContextRepository, successfulAuthentication, unsuccessfulAuthentication

    Methods inherited from class org.springframework.web.filter.GenericFilterBean

    addRequiredProperty, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • alwaysEnabled

      protected boolean alwaysEnabled
    • enabledConfigKey

      protected String enabledConfigKey
    • supportedPrincipalClass

      protected Class<? extends org.springframework.security.core.userdetails.UserDetails> supportedPrincipalClass
  • Constructor Details

    • ConfigAwarePreAuthenticationFilter

      public ConfigAwarePreAuthenticationFilter(String enabledConfigKey)
  • Method Details

    • setAlwaysEnabled

      public void setAlwaysEnabled(boolean alwaysEnabled)
    • setSupportedPrincipalClass

      public void setSupportedPrincipalClass(Class<? extends org.springframework.security.core.userdetails.UserDetails> supportedPrincipalClass)
    • isEnabled

      public boolean isEnabled()
    • doFilter

      public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException
      Specified by:
      doFilter in interface jakarta.servlet.Filter
      Overrides:
      doFilter in class org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter
      Throws:
      IOException
      jakarta.servlet.ServletException
    • principalChanged

      protected boolean principalChanged(jakarta.servlet.http.HttpServletRequest request, org.springframework.security.core.Authentication currentAuthentication)
      Overrides:
      principalChanged in class org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter
    • getPreAuthenticatedCredentials

      protected Object getPreAuthenticatedCredentials(jakarta.servlet.http.HttpServletRequest request)
      Specified by:
      getPreAuthenticatedCredentials in class org.springframework.security.web.authentication.preauth.AbstractPreAuthenticatedProcessingFilter