Class AuthenticationWebFilter

  • All Implemented Interfaces:
    org.springframework.web.server.WebFilter

    public class AuthenticationWebFilter
    extends java.lang.Object
    implements org.springframework.web.server.WebFilter
    A WebFilter that performs authentication of a particular request. An outline of the logic:
    Since:
    5.0
    • Constructor Detail

      • AuthenticationWebFilter

        public AuthenticationWebFilter​(org.springframework.security.authentication.ReactiveAuthenticationManager authenticationManager)
        Creates an instance
        Parameters:
        authenticationManager - the authentication manager to use
      • AuthenticationWebFilter

        public AuthenticationWebFilter​(org.springframework.security.authentication.ReactiveAuthenticationManagerResolver<org.springframework.web.server.ServerWebExchange> authenticationManagerResolver)
        Creates an instance
        Parameters:
        authenticationManagerResolver - the authentication manager resolver to use
        Since:
        5.3
    • Method Detail

      • filter

        public reactor.core.publisher.Mono<java.lang.Void> filter​(org.springframework.web.server.ServerWebExchange exchange,
                                                                  org.springframework.web.server.WebFilterChain chain)
        Specified by:
        filter in interface org.springframework.web.server.WebFilter
      • onAuthenticationSuccess

        protected reactor.core.publisher.Mono<java.lang.Void> onAuthenticationSuccess​(org.springframework.security.core.Authentication authentication,
                                                                                      WebFilterExchange webFilterExchange)
      • setServerAuthenticationConverter

        public void setServerAuthenticationConverter​(ServerAuthenticationConverter authenticationConverter)
        Sets the strategy used for converting from a 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 ServerHttpBasicAuthenticationConverter
        Parameters:
        authenticationConverter - the converter to use
        Since:
        5.1
      • setAuthenticationFailureHandler

        public void setAuthenticationFailureHandler​(ServerAuthenticationFailureHandler authenticationFailureHandler)
        Sets the failure handler used when authentication fails. The default is to prompt for basic authentication.
        Parameters:
        authenticationFailureHandler - the handler to use. Cannot be null.
      • setRequiresAuthenticationMatcher

        public void setRequiresAuthenticationMatcher​(ServerWebExchangeMatcher requiresAuthenticationMatcher)
        Sets the matcher used to determine when creating an Authentication from setServerAuthenticationConverter(ServerAuthenticationConverter) to be authentication. If the converter returns an empty result, then no authentication is attempted. The default is any request
        Parameters:
        requiresAuthenticationMatcher - the matcher to use. Cannot be null.