Class ServerHttpSecurity.OneTimeTokenLoginSpec
java.lang.Object
org.springframework.security.config.web.server.ServerHttpSecurity.OneTimeTokenLoginSpec
- Enclosing class:
- ServerHttpSecurity
Configures One-Time Token Login Support
- Since:
- 6.4
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthenticationConverter(ServerAuthenticationConverter authenticationConverter) Use thisServerAuthenticationConverterwhen converting incoming requests to anAuthentication.authenticationFailureHandler(ServerAuthenticationFailureHandler authenticationFailureHandler) Specifies theServerAuthenticationFailureHandlerto use when authentication fails.authenticationManager(ReactiveAuthenticationManager authenticationManager) SpecifiesReactiveAuthenticationManagerfor one time tokens.authenticationSuccessHandler(Consumer<List<ServerAuthenticationSuccessHandler>> handlersConsumer) Allows customizing the list ofServerAuthenticationSuccessHandler.authenticationSuccessHandler(ServerAuthenticationSuccessHandler authenticationSuccessHandler) Specifies theServerAuthenticationSuccessHandlerprotected voidconfigure(ServerHttpSecurity http) defaultSubmitPageUrl(String submitPageUrl) Sets the URL that the default submit page will be generated.loginProcessingUrl(String loginProcessingUrl) Specifies the URL to process the login request, defaults to/login/ott.securityContextRepository(ServerSecurityContextRepository securityContextRepository) TheServerSecurityContextRepositoryused to save theAuthentication.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(ServerOneTimeTokenGenerationSuccessHandler oneTimeTokenGenerationSuccessHandler) Specifies strategy to be used to handle generated one-time tokens.tokenService(ReactiveOneTimeTokenService oneTimeTokenService) Configures theReactiveOneTimeTokenServiceused to generate and consumeOneTimeToken
-
Constructor Details
-
OneTimeTokenLoginSpec
public OneTimeTokenLoginSpec()
-
-
Method Details
-
configure
-
authenticationSuccessHandler
public ServerHttpSecurity.OneTimeTokenLoginSpec authenticationSuccessHandler(Consumer<List<ServerAuthenticationSuccessHandler>> handlersConsumer) Allows customizing the list ofServerAuthenticationSuccessHandler. The default list contains aRedirectServerAuthenticationSuccessHandlerthat redirects to "/".- Parameters:
handlersConsumer- the handlers consumer- Returns:
- the
ServerHttpSecurity.OneTimeTokenLoginSpecto continue configuring
-
authenticationSuccessHandler
public ServerHttpSecurity.OneTimeTokenLoginSpec authenticationSuccessHandler(ServerAuthenticationSuccessHandler authenticationSuccessHandler) Specifies theServerAuthenticationSuccessHandler- Parameters:
authenticationSuccessHandler- theServerAuthenticationSuccessHandler.
-
authenticationFailureHandler
public ServerHttpSecurity.OneTimeTokenLoginSpec authenticationFailureHandler(ServerAuthenticationFailureHandler authenticationFailureHandler) Specifies theServerAuthenticationFailureHandlerto use when authentication fails. The default is redirecting to "/login?error" usingRedirectServerAuthenticationFailureHandler- Parameters:
authenticationFailureHandler- theServerAuthenticationFailureHandlerto use when authentication fails.
-
authenticationManager
public ServerHttpSecurity.OneTimeTokenLoginSpec authenticationManager(ReactiveAuthenticationManager authenticationManager) SpecifiesReactiveAuthenticationManagerfor one time tokens. Default implementation isOneTimeTokenReactiveAuthenticationManager- Parameters:
authenticationManager-
-
tokenService
public ServerHttpSecurity.OneTimeTokenLoginSpec tokenService(ReactiveOneTimeTokenService oneTimeTokenService) Configures theReactiveOneTimeTokenServiceused to generate and consumeOneTimeToken- Parameters:
oneTimeTokenService-
-
authenticationConverter
public ServerHttpSecurity.OneTimeTokenLoginSpec authenticationConverter(ServerAuthenticationConverter authenticationConverter) Use thisServerAuthenticationConverterwhen converting incoming requests to anAuthentication. By default, theServerOneTimeTokenAuthenticationConverteris used.- Parameters:
authenticationConverter- theServerAuthenticationConverterto use
-
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.- Parameters:
loginProcessingUrl-
-
showDefaultSubmitPage
Configures whether the default one-time token submit page should be shown. This will prevent theOneTimeTokenSubmitPageGeneratingWebFilterto 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-
-
tokenGenerationSuccessHandler
public ServerHttpSecurity.OneTimeTokenLoginSpec tokenGenerationSuccessHandler(ServerOneTimeTokenGenerationSuccessHandler oneTimeTokenGenerationSuccessHandler) Specifies strategy to be used to handle generated one-time tokens.- Parameters:
oneTimeTokenGenerationSuccessHandler-
-
tokenGeneratingUrl
Specifies the URL that a One-Time Token generate request will be processed. Defaults to/ott/generate.- Parameters:
tokenGeneratingUrl-
-
securityContextRepository
public ServerHttpSecurity.OneTimeTokenLoginSpec securityContextRepository(ServerSecurityContextRepository securityContextRepository) TheServerSecurityContextRepositoryused to save theAuthentication. Defaults toWebSessionServerSecurityContextRepository. For theSecurityContextto be loaded on subsequent requests theReactorContextWebFiltermust be configured to be able to load the value (they are not implicitly linked).- Parameters:
securityContextRepository- the repository to use- Returns:
- the
ServerHttpSecurity.OneTimeTokenLoginSpecto continue configuring
-