Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve user not found exception message in InMemoryUserDetailsManager #16497

Closed
jzheaux opened this issue Jan 28, 2025 · 2 comments · Fixed by #16508
Closed

Improve user not found exception message in InMemoryUserDetailsManager #16497

jzheaux opened this issue Jan 28, 2025 · 2 comments · Fixed by #16508
Assignees
Labels
in: core An issue in spring-security-core type: enhancement A general enhancement

Comments

@jzheaux
Copy link
Contributor

jzheaux commented Jan 28, 2025

InMemoryUserDetailsManager adds the username as the exception message for UsernameNotFoundException.

Outside of the context of this exception (for example when wrapped by another exception), the meaning of this message is harder to decipher.

Conventionally, Spring Security uses UsernameNotFoundException with a message like:

new UsernameNotFoundException("user '" + username + "' not found");

Making this change to InMemoryUserDetailsManager will make the exception message more informative and align it's behavior with the rest of Spring Security.

@jzheaux jzheaux added in: core An issue in spring-security-core status: first-timers-only An issue that can only be worked on by brand new contributors type: enhancement A general enhancement labels Jan 28, 2025
@Tejas-Teju
Copy link
Contributor

Hey @jzheaux
Can you assign it to me? Let me make the changes

@jzheaux jzheaux removed the status: first-timers-only An issue that can only be worked on by brand new contributors label Jan 29, 2025
@jzheaux
Copy link
Contributor Author

jzheaux commented Jan 29, 2025

For sure, @Tejas-Teju! I'm excited to work with you on this.

Even though it will likely be a small change, please take a moment to read our contribution guidelines.

Tejas-Teju added a commit to Tejas-Teju/spring-security that referenced this issue Jan 30, 2025
jzheaux pushed a commit to Tejas-Teju/spring-security that referenced this issue Jan 31, 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 a pull request may close this issue.

2 participants