Changing password using Spring security

爷,独闯天下 提交于 2019-11-29 12:37:34

I agree with the answer @jhadesdev;

Note that by calling Spring's JdbcUserDetailsManager.changePassword(), Spring updates the context-holder, plus updates the DB with the new password.

Spring does not handle the cookie, since it does not force your app to be a web application. so I guess if that is the case, a higher level layer in your app should update the session.

PS - out of curiosity - how did you implement the registration flow, and forgot password flow, etc? Spring does not handle this either. I have written a project that takes care of these flows...

A method to change the password is a good solution, as there is no special functionality for this in spring security.

The reason why no special functionality exists for this in spring security, is that it's not needed if using a session.

The user's current session identified by the JSESSIONID cookie is still residing in the user's browser and will still be a valid session after the password change.

When the old password was checked the last time the user logged in, a cookie was generated and kept in a map of valid cookies in memory.

The temporary authentication token (the cookie) is still valid and has a max. lifetime, and changing the password on the database will not impact the current session validity.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!