Я пытаюсь настроить Spring Security для использования с Rest, поэтому я создаю этот файл:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserDetailsService userDetailsService;
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().and().
csrf().disable().
authorizeRequests()
.antMatchers("/home").permitAll()
.antMatchers(HttpMethod.POST, "/login").permitAll()
.anyRequest().authenticated()
.and().formLogin().loginProcessingUrl("/login").failureForwardUrl("/login?erro")
.and().logout().logoutUrl("/logout")
.and().httpBasic().disable();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(authenticationProvider());
}
@Bean
public DaoAuthenticationProvider authenticationProvider() {
DaoAuthenticationProvider authProvider
= new DaoAuthenticationProvider();
authProvider.setUserDetailsService(userDetailsService);
authProvider.setPasswordEncoder(encoder());
return authProvider;
}
@Bean
public PasswordEncoder encoder() {
return new BCryptPasswordEncoder(11);
}
}
Но когда я пытаюсь получить доступ / войти с неверным паролем и именем пользователя, попытаться перенаправить на форму по умолчаниюлогин.
как отключить эту форму по умолчанию?
tks