Hello,
AFAIK Spring Security fires a AuthenticationSuccessEvent after a successful
login - so you should be able to register a listener for this event e.g.:
@Service
public class UserService implements
ApplicationListener<AuthenticationSuccessEvent> {
...
public onApplicationEvent(AuthenticationSuccessEvent event) {
String userName = ((UserDetails) event.getAuthentication().
getPrincipal()).getUsername();
User user = this.userDao.findByLogin(userName);
user.setLastLoginDate(new Date());
}
}
Cheers,
Thomas
2016-04-20 9:17 GMT+02:00 Daniele Capasso Barbato <
daniele.capasso(a)dnshosting.it>:
I develop a rest based api application with spring security and
keycloak.
I'd like to execute custom code when users are log in in to my application
in any rest controller, I try with my filter putting in the last position
of filter chain, but the KeycloakPrincipal in the request is null (seems
that Keycloak value was set after that)
How can I execute custom code when users are login in the right way?
Thanx
_______________________________________________
keycloak-user mailing list
keycloak-user(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/keycloak-user