spring-bootspring-securityldapspring-security-ldap

Spring Security - LDAP Authentication and DB Authorization


In my SpringBoot application, I want to authenticate my user again Enterprise AD and then Authorize (Grant Authorities) from an application-specific database table. Eg: User A authenticated from LDAP and then from DB to get the roles for user A.

I am able to set up LDAP authentication and created a custom UserRepository to fetch the user information and role from the database. But, I am not able to figure out how to plug the two together and get the roles of the authenticated LDAP user.

Thanks in advance.


Solution

  • I think if you provide a LdapAuthoritiesPopulator bean such as the UserDetailsServiceLdapAuthoritiesPopulator and implement your user details service you should be able to set the roles.