Spring Boot + AngularJS + Handle login attemps -
i've followed authenticationfailurebadcredentialsevent - how distinguish between bad password or bad username? creating app. don't understand how login in; it's working far.
i need now, implement logic login attemps. simple "if try login account , fail password 10 times, i'll block user".
here's config custom userdetailsservice implementation:
@autowired public void configureglobal(authenticationmanagerbuilder auth) throws exception { auth .userdetailsservice(userdetailsservice) .passwordencoder(passwordencoder); } customuserdetailsservice overriden loadbyusername function:
@override public userdetails loaduserbyusername(final string login) { user user = userrepository.findbyemail(login); if (user == null) { throw new usernamenotfoundexception(login); } return new user(user.getemail(), user.getpassword(), getauthorities(user.getrole())); } so far i've tried:
1) implement authenticationfailurebadcredentialsevent. works fine, can't distinguish if exception because of user not found, or password wrong, same this
2) implement customauthenticationprovider adding auth.authenticationprovider(customauthenticationprovider) in configureglobal method, couldn't use customuserdetailsservice.
3) implement authenticationfailurehandler works withing formlogin , not "ajax authentication spring-boot + angularjs example".
any clues on this?
Comments
Post a Comment