public class AuthenticationWebFilter
extends java.lang.Object
implements org.springframework.web.server.WebFilter
WebFilter that performs authentication of a particular request. An outline of the logic:
setRequiresAuthenticationMatcher(ServerWebExchangeMatcher),
then this filter does nothing and the WebFilterChain is continued. If it does match then...
ServerWebExchange into an Authentication is made. If the result is
empty, then the filter does nothing more and the WebFilterChain is continued. If it does create an
Authentication...
ReactiveAuthenticationManager specified in
AuthenticationWebFilter(ReactiveAuthenticationManager) is used to perform authentication.
ServerAuthenticationSuccessHandler is invoked and the authentication
is set on ReactiveSecurityContextHolder, else ServerAuthenticationFailureHandler is invoked
| Constructor and Description |
|---|
AuthenticationWebFilter(org.springframework.security.authentication.ReactiveAuthenticationManager authenticationManager)
Creates an instance
|
| Modifier and Type | Method and Description |
|---|---|
reactor.core.publisher.Mono<java.lang.Void> |
filter(org.springframework.web.server.ServerWebExchange exchange,
org.springframework.web.server.WebFilterChain chain) |
void |
setAuthenticationConverter(java.util.function.Function<org.springframework.web.server.ServerWebExchange,reactor.core.publisher.Mono<org.springframework.security.core.Authentication>> authenticationConverter)
Sets the strategy used for converting from a
ServerWebExchange to an Authentication used for
authenticating with the provided ReactiveAuthenticationManager. |
void |
setAuthenticationFailureHandler(ServerAuthenticationFailureHandler authenticationFailureHandler)
Sets the failure handler used when authentication fails.
|
void |
setAuthenticationSuccessHandler(ServerAuthenticationSuccessHandler authenticationSuccessHandler)
Sets the authentication success handler.
|
void |
setRequiresAuthenticationMatcher(ServerWebExchangeMatcher requiresAuthenticationMatcher)
Sets the matcher used to determine when creating an
Authentication from
setAuthenticationConverter(Function) to be authentication. |
void |
setSecurityContextRepository(ServerSecurityContextRepository securityContextRepository)
Sets the repository for persisting the SecurityContext.
|
public AuthenticationWebFilter(org.springframework.security.authentication.ReactiveAuthenticationManager authenticationManager)
authenticationManager - the authentication manager to usepublic reactor.core.publisher.Mono<java.lang.Void> filter(org.springframework.web.server.ServerWebExchange exchange,
org.springframework.web.server.WebFilterChain chain)
filter in interface org.springframework.web.server.WebFilterpublic void setSecurityContextRepository(ServerSecurityContextRepository securityContextRepository)
NoOpServerSecurityContextRepositorysecurityContextRepository - the repository to usepublic void setAuthenticationSuccessHandler(ServerAuthenticationSuccessHandler authenticationSuccessHandler)
WebFilterChainServerAuthenticationSuccessHandlerauthenticationSuccessHandler - the success handler to usepublic void setAuthenticationConverter(java.util.function.Function<org.springframework.web.server.ServerWebExchange,reactor.core.publisher.Mono<org.springframework.security.core.Authentication>> authenticationConverter)
ServerWebExchange to an Authentication used for
authenticating with the provided ReactiveAuthenticationManager. If the result is empty, then it signals
that no authentication attempt should be made. The default converter is
ServerHttpBasicAuthenticationConverterauthenticationConverter - the converter to usepublic void setAuthenticationFailureHandler(ServerAuthenticationFailureHandler authenticationFailureHandler)
authenticationFailureHandler - the handler to use. Cannot be null.public void setRequiresAuthenticationMatcher(ServerWebExchangeMatcher requiresAuthenticationMatcher)
Authentication from
setAuthenticationConverter(Function) to be authentication. If the converter returns an empty
result, then no authentication is attempted. The default is any requestrequiresAuthenticationMatcher - the matcher to use. Cannot be null.