I have a user table containing both MD5 (legacy stuff) and BCrypt password. I would like to migrate MD5 password to BCrypt, without bruteforce them. I thought about re-encrypt passwords on successful authentication.
However (so far in my investigation), I can only get clear password (from login page) if I disable erase-credentials
in authentication-manager
declaration. In this case, I have access to credentials information not only from my custom AuthenticationSuccessHandler
, but from anywhere in my application as well (using SecurityContextHolder.getContext().getAuthentication()
).
Is there a way to access clear password on successful authentication only ? Or do you know a better way to re-encrypt passwords without asking for user manipulation (password change, etc.) ?
Thank you