«Произошла внутренняя ошибка при попытке аутентификации пользователя» из UsernamePasswordAuthenticationFilter - PullRequest
0 голосов
/ 19 февраля 2019

Когда я пытаюсь отправить запрос с другого сервера на моем tomcat (springboot), вижу ошибку.Подскажите, как решить эту проблему?Я использую Java 1.8, Spring: 2.1.2.RELEASE. Проблема именно в том случае, когда сервер обрабатывает запросы от другого сервера.

Ошибка:

2019-02-18 23:37:30.150 ERROR 7444 --- [nio-8080-exec-8] 
w.a.UsernamePasswordAuthenticationFilter : An internal error occurred while 
trying to authenticate the user.

WebMvcConfig:

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    private final long MAX_AGE_SECS = 3600;

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedMethods("HEAD", "OPTIONS", "GET", "POST", "PUT", "PATCH", "DELETE")
                .maxAge(MAX_AGE_SECS);
    }
}

SecurityConfig:

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(securedEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private final UserDetailsServiceImpl userDetailsService;


@Autowired
public SecurityConfig(UserDetailsServiceImpl userDetailsService) {
    this.userDetailsService = userDetailsService;
}

@Override
protected void configure(AuthenticationManagerBuilder auth)
        throws Exception {
    auth
            .userDetailsService(userDetailsService).passwordEncoder(NoOpPasswordEncoder.getInstance());
}

@Bean(name = BeanIds.AUTHENTICATION_MANAGER)
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
    return super.authenticationManagerBean();
}

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
            .cors().and().csrf().disable()
            .authorizeRequests().antMatchers("/resources/**").permitAll()
            .anyRequest().authenticated()
            .and()
            .httpBasic()
            .and()
            .formLogin().loginPage("/login").permitAll()
            .permitAll()
            .defaultSuccessUrl("/user/getrole")
            .and()
            .logout()
            .logoutSuccessUrl("/login")
            .permitAll();
}

}

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...