Ты прав. Вот мой класс SecurityConfig. Теперь я хочу защитить путь как '/ api / **' с базовой аутентификацией.
@Autowired
private CustomAuthenticationProvider authProvider;
@Autowired
DataSource dataSource;
@Autowired
CustomLogoutSuccessHandler customLogoutSuccessHandler;
@Autowired
CustomAuthenticationSuccessHandler customAutheincationSuccessHandler;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authProvider);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/list/**").hasAnyAuthority("Administrator","Operator")
.antMatchers("/api/**").permitAll()
.and()
.formLogin()
.loginPage("/login")
.loginProcessingUrl("/authenticateTheUser")
.successHandler(customAutheincationSuccessHandler)
.and().logout()
.logoutUrl("/logout")
.logoutSuccessHandler(customLogoutSuccessHandler)
.logoutSuccessUrl("/login").and().exceptionHandling().accessDeniedPage("/accessDenied")
.and()
.csrf().disable();
}