How to perform LDAP authorization and database authorization in Spring Security?

I am new to Spring, so this question may look so obvious.

I am trying to implement Spring security, and my requirement is to authenticate the username / password on the LDAP server, and as soon as the user is authenticated, I need to get the user roles from the relational database.

can this be done in spring security?

+3
source share
1 answer

Yes.

Built-in authentication manager ldap divides authentication and user authorization into 2 parts. You can configure LDAP-based authentication manager, as shown below.

<bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
    <property name="providers">
        <list>
            <ref local="ldapAuthenticationProvider"/>
        </list>
    </property> 
</bean>

.

<bean id="ldapAuthenticationProvider" class="org.acegisecurity.providers.ldap.LdapAuthenticationProvider">
    <constructor-arg><ref local="authenticator"/></constructor-arg>
    <constructor-arg><ref local="populator"/></constructor-arg>
    <property name="userCache"><ref local="userCache"/></property>
</bean>

, populator, , , .

+4

Source: https://habr.com/ru/post/1709285/


All Articles