I am new to Spring Security. I have a Spring Boot application with two different types of entities. Customers and employees. In Employees I have normal employees, admins and super users. Since I am using JPA, each entity has its own repository
. How to model my UserDetailsService
with loadUserByUsername
since this is a common method to validate against many repositories. Is there anything that I am missing to model around my entities?
Additional Info:
In my design, I have two entities. Customer
and Employee
. Employee
will have roles like NORMAL
, ADMIN
and SUPER_USER
. Customer is a different entity.
Will there be two UserDetailsService
and two AuthenticationProvider each pointing to its own table (Customer and Employee)?
"Will there be two UserDetailsService and two AuthenticationProvider each pointing to its own table (Customer and Employee)?" ..... The answer is yes.
Spring security has filter, UsernamePasswordAuthenticationFilter (check the name of the filter)where you can implement the specific implementation based on input type.
I did the same thing but for different auth mechanisms. But as per your requirement, it is possible what your looking for.