Моя проблема в том, что при входе в систему безопасности весенней загрузки уже запрашивается токен на предъявителя, пока его нет. Поэтому фильтр не должен выполняться с конкретным запросом, который в моем случае является / authenticate
WebSecurityConfig.java
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
// We don't need CSRF for this example
httpSecurity.csrf().disable()
// dont authenticate this particular request
.authorizeRequests().antMatchers(HttpMethod.POST, "/authenticate", "/register").permitAll().
// all other requests need to be authenticated
anyRequest().authenticated().and().
// make sure we use stateless session; session won't be used to
// store user's state.
exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint).and().sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
// Add a filter to validate the tokens with every request
httpSecurity.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);
}
Но при этом методе фильтры всегда выполняются по любому запросу также/ аутентифицировать который не является намерением.