Find mixed-case usernames in InMemoryUserDetailsManager#changePassword - #19337
Merged
jzheaux merged 1 commit intoAug 13, 2026
Conversation
InMemoryUserDetailsManager keys its user map on the lower-cased username everywhere except changePassword, which looked the current user up with the raw name. A user whose username contains uppercase letters could therefore not change its password. Lower-case the lookup key to match the rest of the class. Closes spring-projectsgh-19336 Signed-off-by: junhyeong9812 <pickjog@gmail.com>
jzheaux
force-pushed
the
fix/inmemoryuserdetailsmanager-changepassword-case
branch
from
August 13, 2026 17:10
02e7f15 to
f467d3b
Compare
Collaborator
|
Thanks, @junhyeong9812! This is now merged into |
Contributor
Author
|
Thanks for merging this, @jzheaux — and thank you for maintaining such a great framework. Happy to contribute back. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
InMemoryUserDetailsManager.changePassword(...)fails for users whose username contains uppercase letters.Problem
The manager keys its
Map<String, MutableUserDetails> userson the lower-cased username increateUser,updateUser,deleteUser,userExists,loadUserByUsername, andupdatePassword. OnlychangePassword(...)looked the current user up with the raw name:So a user created as e.g.
User.withUsername("User")...(stored under the key"user") cannot change its password:users.get("User")isnullandIllegalStateException("Current user doesn't exist in database.")is thrown, even though authentication and every other operation on that user succeed.Fix
Lower-case the lookup key, matching the rest of the class:
A regression test creates the manager with an uppercase username, authenticates as that user, and asserts
changePassword(...)updates the password (observed throughloadUserByUsername).Closes gh-19336