UserDetails not used for security purposes, it is just a "user information" bean. Spring Security uses instances of Authentication . Thus, an Authentication instance usually has only the information necessary for logging in (usernames, credentials and roles in the main). UserDetails is more general and may include everything related to user management (for example, contact information, account information, photos, etc.).
Typically, you will have an Authentication instance supported by the UserDetails instance.
source share