Класс WebSecurityConfig имеет следующий вид: -
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/get*").hasAnyRole();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("user1").password("user1Pass")
.authorities("USER");
//.and().withUser("admin").password("adminPass")
//.authorities("ADMIN");
}
/*@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().passwordEncoder(NoOpPasswordEncoder.getInstance())
.withUser("test").password("test123").roles("USER").and().
withUser("test1").password("test123").roles("ADMIN");
}
}*/
}
Ниже представлен контроллер REST: -
@RequestMapping(value="/getprofessors", method=RequestMethod.GET)
public List<Professor> getProfessors() {
//return service.findProfessors();
List<Professor> Professors = professorRepo.findAll();
return Professors;
}
Ниже изображение представляет вызов POSTMAN, который я выполняю: -
Ошибка получения 403 при доступе к этому контроллеру, даже если не указана роль.