I have the following Spring Security configuration:
httpSecurity .csrf() .disable() .exceptionHandling() .authenticationEntryPoint(unauthorizedHandler) .and() .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .authorizeRequests() .antMatchers("/api/**").fullyAuthenticated() .and() .addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class); The authenticationTokenFilterBean() is applied even on endpoints that do not match /api/** expression. I also tried adding the following configuration code
@Override public void configure(WebSecurity webSecurity) { webSecurity.ignoring().antMatchers("/some_endpoint"); } but this still did not solve my problem. How can I tell spring security to apply filters only on endpoints that match the secured URI expression? Thank you