Class HttpSecurity.RequestMatcherConfigurer

java.lang.Object
org.springframework.security.config.annotation.web.AbstractRequestMatcherRegistry<HttpSecurity.RequestMatcherConfigurer>
org.springframework.security.config.annotation.web.builders.HttpSecurity.RequestMatcherConfigurer
Enclosing class:
HttpSecurity

public class HttpSecurity.RequestMatcherConfigurer extends AbstractRequestMatcherRegistry<HttpSecurity.RequestMatcherConfigurer>
Allows mapping HTTP requests that this HttpSecurity will be used for
Since:
3.2
  • Field Details

    • matchers

      protected List<org.springframework.security.web.util.matcher.RequestMatcher> matchers
  • Method Details

    • chainRequestMatchers

      protected HttpSecurity.RequestMatcherConfigurer chainRequestMatchers(List<org.springframework.security.web.util.matcher.RequestMatcher> requestMatchers)
      Description copied from class: AbstractRequestMatcherRegistry
      Subclasses should implement this method for returning the object that is chained to the creation of the RequestMatcher instances.
      Specified by:
      chainRequestMatchers in class AbstractRequestMatcherRegistry<HttpSecurity.RequestMatcherConfigurer>
      Parameters:
      requestMatchers - the RequestMatcher instances that were created
      Returns:
      the chained Object for the subclass which allows association of something else to the RequestMatcher
    • and

      @Deprecated(since="6.1", forRemoval=true) public HttpSecurity and()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use the lambda based configuration instead. For example:
       @Configuration
       @EnableWebSecurity
       public class SecurityConfig {
      
           @Bean
           public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
               http
                   .securityMatchers((matchers) -> matchers
                       .requestMatchers("/api/**")
                   )
                   .authorizeHttpRequests((authorize) -> authorize
                       .anyRequest().hasRole("USER")
                   )
                   .httpBasic(Customizer.withDefaults());
               return http.build();
           }
      
       }
       
      Return the HttpSecurity for further customizations
      Returns:
      the HttpSecurity for further customizations