Fake UserDetailsService if none is specified is unnecessary #14632
Labels
in: config
An issue in spring-security-config
status: declined
A suggestion or change that we don't feel we should currently apply
type: enhancement
A general enhancement
If I have a security application that doesn't actually perform any authentication and just parses an
Authorization
header for a JWT token (a separate service that issues them may, on the other hand, perform some authentication), I'm unlikly to actually register anyAuthenticationManager
s orUserDetailsService
s. As a result, I will likely trigger all these conditionals and have a pointlessUserDetailsService
that matches against its in-memory map of one fake user in my contextBesides, it reflects on my console output (in case the password stays a random UUID, the config prints this info message):
It's not a tragedy since I don't inject it anywhere, but it feels wrong. I could register some stub
AuthenticationManager
to avoid a match, but it's a kludge. Frankly, I don't see any purpose in extending Spring's autoconfiguration magic toUserDetailsService
. Even when you only start learning Spring Security, you can easily register some simple implementation, as you showed in your tutorial. In fact, it's even less straightforward for a beginner to go looking in their console output for the default password for their default user (which they may never suspect about)The text was updated successfully, but these errors were encountered: