Class AbstractAuthenticationFilterConfigurer<B extends HttpSecurityBuilder<B>,T extends AbstractAuthenticationFilterConfigurer<B,T,F>,F extends org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter>
java.lang.Object
org.springframework.security.config.annotation.SecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,B>
org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer<T,B>
org.springframework.security.config.annotation.web.configurers.AbstractAuthenticationFilterConfigurer<B,T,F>
- Type Parameters:
T- refers to "this" for returning the current configurerF- refers to theAbstractAuthenticationProcessingFilterthat is being built
- All Implemented Interfaces:
SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,B>
- Direct Known Subclasses:
FormLoginConfigurer,OAuth2LoginConfigurer,OneTimeTokenLoginConfigurer,Saml2LoginConfigurer
public abstract class AbstractAuthenticationFilterConfigurer<B extends HttpSecurityBuilder<B>,T extends AbstractAuthenticationFilterConfigurer<B,T,F>,F extends org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter>
extends AbstractHttpConfigurer<T,B>
Base class for configuring
AbstractAuthenticationFilterConfigurer. This is
intended for internal use only.- Since:
- 3.2
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new instance with minimal defaultsprotectedAbstractAuthenticationFilterConfigurer(F authenticationFilter, String defaultLoginProcessingUrl) Creates a new instance -
Method Summary
Modifier and TypeMethodDescriptionfinal TauthenticationDetailsSource(org.springframework.security.authentication.AuthenticationDetailsSource<jakarta.servlet.http.HttpServletRequest, ?> authenticationDetailsSource) Specifies a customAuthenticationDetailsSource.voidConfigure theSecurityBuilderby setting the necessary properties on theSecurityBuilder.protected abstract org.springframework.security.web.util.matcher.RequestMatchercreateLoginProcessingUrlMatcher(String loginProcessingUrl) Create theRequestMatchergiven a loginProcessingUrlfinal TdefaultSuccessUrl(String defaultSuccessUrl) Specifies where users will be redirected after authenticating successfully if they have not visited a secured page prior to authenticating.final TdefaultSuccessUrl(String defaultSuccessUrl, boolean alwaysUse) Specifies where users will be redirected after authenticating successfully if they have not visited a secured page prior to authenticating oralwaysUseis true.final TfailureHandler(org.springframework.security.web.authentication.AuthenticationFailureHandler authenticationFailureHandler) Specifies theAuthenticationFailureHandlerto use when authentication fails.final TfailureUrl(String authenticationFailureUrl) The URL to send users if authentication fails.protected final org.springframework.security.web.AuthenticationEntryPointGets the Authentication Entry Pointprotected final org.springframework.security.web.util.matcher.RequestMatcherprotected final FGets the Authentication Filterprotected final StringGets the URL to send users to if authentication failsprotected final StringGets the login pageprotected final StringGets the URL to submit an authentication request to (i.e.voidInitialize theSecurityBuilder.final booleanprotected TSpecifies the URL to send users to if login is required.loginProcessingUrl(String loginProcessingUrl) Specifies the URL to validate the credentials.final TEquivalent of invoking permitAll(true)final TpermitAll(boolean permitAll) Ensures the urls forfailureUrl(String)as well as for theHttpSecurityBuilder, thegetLoginPage()andgetLoginProcessingUrl()are granted access to any user.protected final voidregisterAuthenticationEntryPoint(B http, org.springframework.security.web.AuthenticationEntryPoint authenticationEntryPoint) protected final voidsecurityContextRepository(org.springframework.security.web.context.SecurityContextRepository securityContextRepository) protected final voidsetAuthenticationFilter(F authFilter) Sets the Authentication Filterfinal TsuccessHandler(org.springframework.security.web.authentication.AuthenticationSuccessHandler successHandler) Specifies theAuthenticationSuccessHandlerto be used.protected final voidupdateAccessDefaults(B http) Updates the default values for access.protected final voidUpdates the default values for authentication.Methods inherited from class org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer
disable, getSecurityContextHolderStrategy, withObjectPostProcessor, withObjectPostProcessorMethods inherited from class org.springframework.security.config.annotation.SecurityConfigurerAdapter
addObjectPostProcessor, addObjectPostProcessor, and, getBuilder, postProcess, setBuilder
-
Constructor Details
-
AbstractAuthenticationFilterConfigurer
protected AbstractAuthenticationFilterConfigurer()Creates a new instance with minimal defaults -
AbstractAuthenticationFilterConfigurer
protected AbstractAuthenticationFilterConfigurer(F authenticationFilter, String defaultLoginProcessingUrl) Creates a new instance- Parameters:
authenticationFilter- theAbstractAuthenticationProcessingFilterto usedefaultLoginProcessingUrl- the default URL to use forloginProcessingUrl(String)
-
-
Method Details
-
defaultSuccessUrl
Specifies where users will be redirected after authenticating successfully if they have not visited a secured page prior to authenticating. This is a shortcut for callingdefaultSuccessUrl(String, boolean).- Parameters:
defaultSuccessUrl- the default success url- Returns:
- the
FormLoginConfigurerfor additional customization
-
defaultSuccessUrl
Specifies where users will be redirected after authenticating successfully if they have not visited a secured page prior to authenticating oralwaysUseis true. This is a shortcut for callingsuccessHandler(AuthenticationSuccessHandler).- Parameters:
defaultSuccessUrl- the default success urlalwaysUse- true if thedefaultSuccessUrlshould be used after authentication despite if a protected page had been previously visited- Returns:
- the
FormLoginConfigurerfor additional customization
-
loginProcessingUrl
Specifies the URL to validate the credentials.- Parameters:
loginProcessingUrl- the URL to validate username and password- Returns:
- the
FormLoginConfigurerfor additional customization
-
securityContextRepository
public T securityContextRepository(org.springframework.security.web.context.SecurityContextRepository securityContextRepository) -
createLoginProcessingUrlMatcher
protected abstract org.springframework.security.web.util.matcher.RequestMatcher createLoginProcessingUrlMatcher(String loginProcessingUrl) Create theRequestMatchergiven a loginProcessingUrl- Parameters:
loginProcessingUrl- creates theRequestMatcherbased upon the loginProcessingUrl- Returns:
- the
RequestMatcherto use based upon the loginProcessingUrl
-
authenticationDetailsSource
public final T authenticationDetailsSource(org.springframework.security.authentication.AuthenticationDetailsSource<jakarta.servlet.http.HttpServletRequest, ?> authenticationDetailsSource) Specifies a customAuthenticationDetailsSource. The default isWebAuthenticationDetailsSource.- Parameters:
authenticationDetailsSource- the customAuthenticationDetailsSource- Returns:
- the
FormLoginConfigurerfor additional customization
-
successHandler
public final T successHandler(org.springframework.security.web.authentication.AuthenticationSuccessHandler successHandler) Specifies theAuthenticationSuccessHandlerto be used. The default isSavedRequestAwareAuthenticationSuccessHandlerwith no additional properties set.- Parameters:
successHandler- theAuthenticationSuccessHandler.- Returns:
- the
FormLoginConfigurerfor additional customization
-
permitAll
Equivalent of invoking permitAll(true)- Returns:
- the
FormLoginConfigurerfor additional customization
-
permitAll
Ensures the urls forfailureUrl(String)as well as for theHttpSecurityBuilder, thegetLoginPage()andgetLoginProcessingUrl()are granted access to any user.- Parameters:
permitAll- true to grant access to the URLs false to skip this step- Returns:
- the
FormLoginConfigurerfor additional customization
-
failureUrl
The URL to send users if authentication fails. This is a shortcut for invokingfailureHandler(AuthenticationFailureHandler). The default is "/login?error".- Parameters:
authenticationFailureUrl- the URL to send users if authentication fails (i.e. "/login?error").- Returns:
- the
FormLoginConfigurerfor additional customization
-
failureHandler
public final T failureHandler(org.springframework.security.web.authentication.AuthenticationFailureHandler authenticationFailureHandler) Specifies theAuthenticationFailureHandlerto use when authentication fails. The default is redirecting to "/login?error" usingSimpleUrlAuthenticationFailureHandler- Parameters:
authenticationFailureHandler- theAuthenticationFailureHandlerto use when authentication fails.- Returns:
- the
FormLoginConfigurerfor additional customization
-
init
Description copied from interface:SecurityConfigurerInitialize theSecurityBuilder. Here only shared state should be created and modified, but not properties on theSecurityBuilderused for building the object. This ensures that theSecurityConfigurer.configure(SecurityBuilder)method uses the correct shared objects when building. Configurers should be applied here.- Specified by:
initin interfaceSecurityConfigurer<B extends HttpSecurityBuilder<B>,T extends AbstractAuthenticationFilterConfigurer<B, T, F>> - Overrides:
initin classSecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,B extends HttpSecurityBuilder<B>> - Throws:
Exception
-
registerDefaultAuthenticationEntryPoint
-
registerAuthenticationEntryPoint
protected final void registerAuthenticationEntryPoint(B http, org.springframework.security.web.AuthenticationEntryPoint authenticationEntryPoint) -
getAuthenticationEntryPointMatcher
protected final org.springframework.security.web.util.matcher.RequestMatcher getAuthenticationEntryPointMatcher(B http) -
configure
Description copied from interface:SecurityConfigurerConfigure theSecurityBuilderby setting the necessary properties on theSecurityBuilder.- Specified by:
configurein interfaceSecurityConfigurer<B extends HttpSecurityBuilder<B>,T extends AbstractAuthenticationFilterConfigurer<B, T, F>> - Overrides:
configurein classSecurityConfigurerAdapter<org.springframework.security.web.DefaultSecurityFilterChain,B extends HttpSecurityBuilder<B>> - Throws:
Exception
-
loginPage
Specifies the URL to send users to if login is required. If used with
EnableWebSecuritya default login page will be generated when this attribute is not specified.If a URL is specified or this is not being used in conjunction with
EnableWebSecurity, users are required to process the specified URL to generate a login page. -
isCustomLoginPage
public final boolean isCustomLoginPage()- Returns:
- true if a custom login page has been specified, else false
-
getAuthenticationFilter
Gets the Authentication Filter- Returns:
- the Authentication Filter
-
setAuthenticationFilter
Sets the Authentication Filter- Parameters:
authFilter- the Authentication Filter
-
getLoginPage
Gets the login page- Returns:
- the login page
-
getAuthenticationEntryPoint
protected final org.springframework.security.web.AuthenticationEntryPoint getAuthenticationEntryPoint()Gets the Authentication Entry Point- Returns:
- the Authentication Entry Point
-
getLoginProcessingUrl
Gets the URL to submit an authentication request to (i.e. where username/password must be submitted)- Returns:
- the URL to submit an authentication request to
-
getFailureUrl
Gets the URL to send users to if authentication fails- Returns:
- the URL to send users if authentication fails (e.g. "/login?error").
-
updateAuthenticationDefaults
protected final void updateAuthenticationDefaults()Updates the default values for authentication. -
updateAccessDefaults
Updates the default values for access.
-