Я хочу аутентифицировать пользователя с помощью метода POST в весенней безопасности. Сообщение попадает в метод контроллера, но пользователь никогда не проходит аутентификацию. Вот сценарий
@Autowired
private AuthenticationManagerBuilder builder;
@RequestMapping(value="/signin", method = RequestMethod.POST)
public ResponseData<Client> login(@RequestParam(value="username") String name, @RequestParam(value="password") String password,HttpServletRequest req) {
System.out.println("here..."); //this executes
Client ac = accountRepository.findByEmailAndActive(name,true);
//does the authentication
final Authentication authentication = builder.getOrBuild().authenticate(
new UsernamePasswordAuthenticationToken(
name,
password
)
);
SecurityContextHolder.getContext().setAuthentication(authentication);
return ResponseData.successData(ac);
}
Это мои весенние методы безопасности / обработчик
.antMatchers(HttpMethod.POST,"/signin").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login").defaultSuccessUrl("/index")
.loginProcessingUrl("/signin2")
.permitAll()
.and()
.logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login?logout=true")
.deleteCookies("JSESSIONID", "remember-me")
.invalidateHttpSession(true)
.and().csrf().disable()
.rememberMe().tokenRepository(persistentTokenRepository()).tokenValiditySeconds(1200000);
Пожалуйста, помогите