Search⌘ K

Spring Security Connection

Understand how to implement Spring Security in a Thymeleaf application by connecting user data stored in a database. Learn to create custom UserDetails and UserDetailsService implementations, handle encrypted passwords, and configure security settings to enable user authentication with email login.

Establishing connection

We need two things to make the connection possible:

  • An implementation of the org.springframework.security.core.userdetails.UserDetailsService interface.

  • An implementation of the org.springframework.security.core.userdetails.UserDetails interface.

The UserDetailsService1 interface has a single method that takes a string. This parameter is the username or the email, depending on what users use to log on. The method returns an instance of UserDetails or throws an org.springframework.security.core.userdetails.UsernameNotFoundException if no ...