У меня есть следующий адаптер безопасности для моей службы Spring REST, чтобы использовать HTTP базовую аутентификацию http.Прямо сейчас, когда я пытаюсь отправить запрос к любой конечной точке GET HTTP, запрос успешно авторизуется и обрабатывается.Но все другие методы HTTP возвращают 401. Любая идея?
@EnableWebSecurity
public class WebSecurityAdapter extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("user").password(passwordEncoder().encode("password")).roles("USER");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/**").hasRole("USER").and().httpBasic();
}
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}