Spring security permit all is not working for multiple urls

Viewed 1205

I'm trying to give permit all to multiple urls but I'm getting 403. When I disable csrf, all the requests are working without authentication. Pls find below my security configuration.

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable()
                .authorizeRequests()//.anyRequest().permitAll()
                .antMatchers("/actuator/**","/v1/foo/link")
                .permitAll()
                .antMatchers("/**")
                .authenticated()
                .and()
                .oauth2ResourceServer()
                .jwt(withDefaults());
    }
}

Please correct me where I'm missing. Thank you..

1 Answers
Related