Skip to content

Implement UserDetailsPasswordService in JdbcUserDetailsManager - #17071

Merged
rwinch merged 2 commits into
spring-projects:mainfrom
jhl221123:gh-16863
May 14, 2025
Merged

rwinch merged 2 commits into
spring-projects:mainfrom
jhl221123:gh-16863

Conversation

@jhl221123

Copy link
Copy Markdown
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

Copy link
Copy Markdown

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) {

Copy link
Copy Markdown

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

rwinch commented May 14, 2025

Copy link
Copy Markdown
Member

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

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