Для проекта без пружинной защиты. Все контроллеры (GET / POST) проекта не защищены и не должны быть защищены. Но теперь у меня есть новый контроллер, и я хочу защитить его путь (/private
), вложенные пути и параметры. Только этот единственный путь должен быть защищен с помощью Basi c Authentication. Почему мой код не работает?
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/**").permitAll()
.antMatchers("/private**").hasAuthority("ADMIN").and().httpBasic();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("user")
.password("{noop}pass")
.roles("ADMIN");
}
}