Skip to content

Conversation

jhl221123
Copy link
Contributor

Summary:

Implements UserDetailsPasswordService in JdbcUserDetailsManager to allow password updates, controlled by a new flag.

Changes:

  • Added updatePassword(UserDetails user, String newPassword) method.
  • Introduced enableUpdatePassword boolean property (default: false) and setter setEnableUpdatePassword(boolean).
  • updatePassword method logic updated:
    • If enableUpdatePassword is true, it updates the user's password via updateUser.
    • If enableUpdatePassword is false, it returns the original UserDetails without performing any update.
  • Added tests in JdbcUserDetailsManagerTests to verify both scenarios (updatePasswordWhenDisabledReturnOriginalUser and updatePasswordWhenEnabledShouldUpdatePassword).

Closes gh-16863

Signed-off-by: Junhyeok Lee <jhl221123@naver.com>
@@ -65,7 +66,8 @@
* @author Luke Taylor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add your name on here?

Comment on lines +624 to +625
@Override
public UserDetails updatePassword(UserDetails user, String newPassword) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Override
public UserDetails updatePassword(UserDetails user, String newPassword) {
@Override
/**
* comments like "updatePassword only when {@link #enableUpdatePassword} is true?
*/
public UserDetails updatePassword(UserDetails user, String newPassword) {

nit. how about adding comment about updatePassword flag?

Signed-off-by: Junhyeok Lee <jhl221123@naver.com>
@rwinch rwinch self-assigned this May 14, 2025
@rwinch rwinch added in: core An issue in spring-security-core type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels May 14, 2025
@rwinch rwinch enabled auto-merge (rebase) May 14, 2025 18:27
@rwinch
Copy link
Member

rwinch commented May 14, 2025

Thank you for the PR @jhl221123! This is now queued to be merged into main as soon as the build passes

@rwinch rwinch merged commit e30dc42 into spring-projects:main May 14, 2025
4 checks passed
@ngocnhan-tran1996 ngocnhan-tran1996 mentioned this pull request May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JdbcUserDetailsManager.setEnableUpdatePassword
4 participants