Попробуйте добавить .anyRequest().authenticated()
, значит, все запросы должны быть аутентифицированы.Если вы хотите добавить исключение, добавьте что-то вроде .antMatchers(HttpMethod.GET, "/", "/js/**", "/css/*", "/images/**").permitAll()
, это не будет аутентифицировано.
Пример кода:
@Configuration
@EnableWebSecurity
public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests()
.antMatchers(HttpMethod.GET, "/", "/js/**", "/css/*", "/images/**").permitAll()
.anyRequest().authenticated();
}
}