Class OneTimeTokenLoginConfigurer<H extends HttpSecurityBuilder<H>>
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<H,OneTimeTokenLoginConfigurer<H>,org.springframework.security.web.authentication.ott.OneTimeTokenAuthenticationFilter>
org.springframework.security.config.annotation.web.configurers.ott.OneTimeTokenLoginConfigurer<H>
- All Implemented Interfaces:
SecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,H>
public final class OneTimeTokenLoginConfigurer<H extends HttpSecurityBuilder<H>>
extends AbstractAuthenticationFilterConfigurer<H,OneTimeTokenLoginConfigurer<H>,org.springframework.security.web.authentication.ott.OneTimeTokenAuthenticationFilter>
An
AbstractHttpConfigurer for One-Time Token Login.
One-Time Token Login provides an application with the capability to have users log in by obtaining a single-use token out of band, for example through email.
Defaults are provided for all configuration options, with the only required
configuration being
tokenGenerationSuccessHandler(OneTimeTokenGenerationSuccessHandler).
Alternatively, a OneTimeTokenGenerationSuccessHandler @Bean may be
registered instead.
Security Filters
The followingFilters are populated:
DefaultOneTimeTokenSubmitPageGeneratingFilterGenerateOneTimeTokenFilterOneTimeTokenAuthenticationFilter
Shared Objects Used
The following shared objects are used:DefaultLoginPageGeneratingFilter- ifloginPage(String)is not configured andDefaultLoginPageGeneratingFilteris available, then a default login page will be made available
- Since:
- 6.4
- See Also:
-
HttpSecurity.oneTimeTokenLogin(Customizer)DefaultOneTimeTokenSubmitPageGeneratingFilterGenerateOneTimeTokenFilterOneTimeTokenAuthenticationFilterAbstractAuthenticationFilterConfigurer
-
Constructor Summary
ConstructorsConstructorDescriptionOneTimeTokenLoginConfigurer(org.springframework.context.ApplicationContext context) -
Method Summary
Modifier and TypeMethodDescriptionauthenticationConverter(org.springframework.security.web.authentication.AuthenticationConverter authenticationConverter) Use thisAuthenticationConverterwhen converting incoming requests to anAuthentication.authenticationFailureHandler(org.springframework.security.web.authentication.AuthenticationFailureHandler authenticationFailureHandler) Deprecated.authenticationProvider(org.springframework.security.authentication.AuthenticationProvider authenticationProvider) Specifies theAuthenticationProviderto use when authenticating the user.authenticationSuccessHandler(org.springframework.security.web.authentication.AuthenticationSuccessHandler authenticationSuccessHandler) Deprecated.voidConfigure theSecurityBuilderby setting the necessary properties on theSecurityBuilder.protected org.springframework.security.web.util.matcher.RequestMatchercreateLoginProcessingUrlMatcher(String loginProcessingUrl) Create theRequestMatchergiven a loginProcessingUrldefaultSubmitPageUrl(String submitPageUrl) Sets the URL that the default submit page will be generated.generateRequestResolver(org.springframework.security.web.authentication.ott.GenerateOneTimeTokenRequestResolver requestResolver) Use thisGenerateOneTimeTokenRequestResolverwhen resolvingGenerateOneTimeTokenRequestfromHttpServletRequest.org.springframework.context.ApplicationContextDeprecated.Use this.context insteadvoidInitialize theSecurityBuilder.Specifies the URL to send users to if login is required.loginProcessingUrl(String loginProcessingUrl) Specifies the URL to process the login request, defaults to/login/ott.showDefaultSubmitPage(boolean show) Configures whether the default one-time token submit page should be shown.tokenGeneratingUrl(String tokenGeneratingUrl) Specifies the URL that a One-Time Token generate request will be processed.tokenGenerationSuccessHandler(org.springframework.security.web.authentication.ott.OneTimeTokenGenerationSuccessHandler oneTimeTokenGenerationSuccessHandler) Specifies strategy to be used to handle generated one-time tokens.tokenService(org.springframework.security.authentication.ott.OneTimeTokenService oneTimeTokenService) Configures theOneTimeTokenServiceused to generate and consumeOneTimeTokenMethods inherited from class org.springframework.security.config.annotation.web.configurers.AbstractAuthenticationFilterConfigurer
authenticationDetailsSource, defaultSuccessUrl, defaultSuccessUrl, failureHandler, failureUrl, getAuthenticationEntryPoint, getAuthenticationEntryPointMatcher, getAuthenticationFilter, getFailureUrl, getLoginPage, getLoginProcessingUrl, isCustomLoginPage, permitAll, permitAll, registerAuthenticationEntryPoint, registerDefaultAuthenticationEntryPoint, securityContextRepository, setAuthenticationFilter, successHandler, updateAccessDefaults, updateAuthenticationDefaultsMethods 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
-
OneTimeTokenLoginConfigurer
public OneTimeTokenLoginConfigurer(org.springframework.context.ApplicationContext context)
-
-
Method Details
-
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<org.springframework.security.web.DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>> - Overrides:
initin classAbstractAuthenticationFilterConfigurer<H extends HttpSecurityBuilder<H>,OneTimeTokenLoginConfigurer<H extends HttpSecurityBuilder<H>>, org.springframework.security.web.authentication.ott.OneTimeTokenAuthenticationFilter> - Throws:
Exception
-
configure
Description copied from interface:SecurityConfigurerConfigure theSecurityBuilderby setting the necessary properties on theSecurityBuilder.- Specified by:
configurein interfaceSecurityConfigurer<org.springframework.security.web.DefaultSecurityFilterChain,H extends HttpSecurityBuilder<H>> - Overrides:
configurein classAbstractAuthenticationFilterConfigurer<H extends HttpSecurityBuilder<H>,OneTimeTokenLoginConfigurer<H extends HttpSecurityBuilder<H>>, org.springframework.security.web.authentication.ott.OneTimeTokenAuthenticationFilter> - Throws:
Exception
-
createLoginProcessingUrlMatcher
protected org.springframework.security.web.util.matcher.RequestMatcher createLoginProcessingUrlMatcher(String loginProcessingUrl) Description copied from class:AbstractAuthenticationFilterConfigurerCreate theRequestMatchergiven a loginProcessingUrl- Specified by:
createLoginProcessingUrlMatcherin classAbstractAuthenticationFilterConfigurer<H extends HttpSecurityBuilder<H>,OneTimeTokenLoginConfigurer<H extends HttpSecurityBuilder<H>>, org.springframework.security.web.authentication.ott.OneTimeTokenAuthenticationFilter> - Parameters:
loginProcessingUrl- creates theRequestMatcherbased upon the loginProcessingUrl- Returns:
- the
RequestMatcherto use based upon the loginProcessingUrl
-
authenticationProvider
public OneTimeTokenLoginConfigurer<H> authenticationProvider(org.springframework.security.authentication.AuthenticationProvider authenticationProvider) Specifies theAuthenticationProviderto use when authenticating the user.- Parameters:
authenticationProvider-
-
tokenGeneratingUrl
Specifies the URL that a One-Time Token generate request will be processed. Defaults to/ott/generate.- Parameters:
tokenGeneratingUrl-
-
tokenGenerationSuccessHandler
public OneTimeTokenLoginConfigurer<H> tokenGenerationSuccessHandler(org.springframework.security.web.authentication.ott.OneTimeTokenGenerationSuccessHandler oneTimeTokenGenerationSuccessHandler) Specifies strategy to be used to handle generated one-time tokens.- Parameters:
oneTimeTokenGenerationSuccessHandler-
-
loginProcessingUrl
Specifies the URL to process the login request, defaults to/login/ott. Only POST requests are processed, for that reason make sure that you pass a valid CSRF token if CSRF protection is enabled.- Overrides:
loginProcessingUrlin classAbstractAuthenticationFilterConfigurer<H extends HttpSecurityBuilder<H>,OneTimeTokenLoginConfigurer<H extends HttpSecurityBuilder<H>>, org.springframework.security.web.authentication.ott.OneTimeTokenAuthenticationFilter> - Parameters:
loginProcessingUrl-- Returns:
- the
FormLoginConfigurerfor additional customization - See Also:
-
loginPage
Specifies the URL to send users to if login is required. If used withEnableWebSecuritya default login page will be generated when this attribute is not specified.- Overrides:
loginPagein classAbstractAuthenticationFilterConfigurer<H extends HttpSecurityBuilder<H>,OneTimeTokenLoginConfigurer<H extends HttpSecurityBuilder<H>>, org.springframework.security.web.authentication.ott.OneTimeTokenAuthenticationFilter> - Parameters:
loginPage-
-
showDefaultSubmitPage
Configures whether the default one-time token submit page should be shown. This will prevent theDefaultOneTimeTokenSubmitPageGeneratingFilterto be configured.- Parameters:
show-
-
defaultSubmitPageUrl
Sets the URL that the default submit page will be generated. Defaults to/login/ott. If you don't want to generate the default submit page you should useshowDefaultSubmitPage(boolean). Note that this method always invokeshowDefaultSubmitPage(boolean)passingtrue.- Parameters:
submitPageUrl-
-
tokenService
public OneTimeTokenLoginConfigurer<H> tokenService(org.springframework.security.authentication.ott.OneTimeTokenService oneTimeTokenService) Configures theOneTimeTokenServiceused to generate and consumeOneTimeToken- Parameters:
oneTimeTokenService-
-
authenticationConverter
public OneTimeTokenLoginConfigurer<H> authenticationConverter(org.springframework.security.web.authentication.AuthenticationConverter authenticationConverter) Use thisAuthenticationConverterwhen converting incoming requests to anAuthentication. By default, theOneTimeTokenAuthenticationConverteris used.- Parameters:
authenticationConverter- theAuthenticationConverterto use
-
authenticationFailureHandler
@Deprecated(since="6.5") public OneTimeTokenLoginConfigurer<H> authenticationFailureHandler(org.springframework.security.web.authentication.AuthenticationFailureHandler authenticationFailureHandler) Deprecated.Specifies theAuthenticationFailureHandlerto use when authentication fails. The default is redirecting to "/login?error" usingSimpleUrlAuthenticationFailureHandler- Parameters:
authenticationFailureHandler- theAuthenticationFailureHandlerto use when authentication fails.
-
authenticationSuccessHandler
@Deprecated(since="6.5") public OneTimeTokenLoginConfigurer<H> authenticationSuccessHandler(org.springframework.security.web.authentication.AuthenticationSuccessHandler authenticationSuccessHandler) Deprecated.Specifies theAuthenticationSuccessHandlerto be used. The default isSavedRequestAwareAuthenticationSuccessHandlerwith no additional properties set.- Parameters:
authenticationSuccessHandler- theAuthenticationSuccessHandler.
-
generateRequestResolver
public OneTimeTokenLoginConfigurer<H> generateRequestResolver(org.springframework.security.web.authentication.ott.GenerateOneTimeTokenRequestResolver requestResolver) Use thisGenerateOneTimeTokenRequestResolverwhen resolvingGenerateOneTimeTokenRequestfromHttpServletRequest. By default, theDefaultGenerateOneTimeTokenRequestResolveris used.- Parameters:
requestResolver- theGenerateOneTimeTokenRequestResolver- Since:
- 6.5
-
getContext
Deprecated.Use this.context instead
-
AbstractAuthenticationFilterConfigurer.failureHandler(AuthenticationFailureHandler)instead