Угловой 6 + пружинный каркас 5 + пружинный предохранитель - PullRequest
0 голосов
/ 01 июня 2018

Я построил проект весной 5. Затем я начал настраивать вход в систему в угловых (CORS), но он просто дает мне ошибку 401 в предварительных настройках параметров.Я застрял с этим, если у вас есть что-то, чтобы помочь, дайте мне знать.Внутренний проект: https://github.com/maiconpintoabreu/Spring5SecurityMongodbTest Спасибо

Исправлено с конфигурацией @Order и Cors

@Order(4)  

открытый класс WebSecurityConfiguration extends WebSecurityConfigurerAdapter {

...

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
        .authorizeRequests()
        .antMatchers("/**").hasAnyRole("ADMIN","USER")
        .antMatchers(HttpMethod.OPTIONS, "**").permitAll()
        .antMatchers("/resources/**").permitAll()
        .anyRequest().authenticated().and()
        .httpBasic().and().cors().and();           
}
@Bean
CorsConfigurationSource corsConfigurationSource() {
  UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
  source.registerCorsConfiguration("/**", new CorsConfiguration().applyPermitDefaultValues());
  return source;
}

}

...