I am trying to migrate from Springboot 2.7 to Springboot 3.1.2 . I am trying to configure my security config class. This is my class
@Bean
public SecurityFilterChain filterChain(HttpSecurity http, MvcRequestMatcher.Builder mvc) throws Exception {
http
.csrf(AbstractHttpConfigurer :: disable)
.authorizeHttpRequests(request -> request.requestMatchers(mvc.pattern("/api/dummy/***"))
.permitAll()
.anyRequest().authenticated())
.sessionManagement(manager ->manager.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.authenticationProvider(authenticationProvider)
.addFilterBefore(new AuthTokenFilter(serviceA, serviceB),AuthenticationFilter.class);
return http.build();
}
I want the /api/dummy/**
api to pass without any filter and want the filter to be applied for all the other requests. But currently, all my apis, irrespective of any request matching is going through the addFilterBefore
method and going inside AuthTokenFilter class.
Can anyone please help me solve the issue so that the mentioned API does not go through the authTokenFilter and rest of the APIs go.
I have tried to configure the same in all the possible ways found in the internet, still its not working. Any help would be much appreciated.
Somdyuti Das Gupta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.