繁体   English   中英

在Spring Security中如何进行LDAP身份验证和数据库授权

[英]How to do LDAP authentication and DataBase authorization in Spring Security

我可以有一个Spring Security项目,在该项目中我可以根据LDAP进行身份验证,并根据数据库将身份验证的用户设置为授权人吗?

谢谢!

我已经实现了解决方案,答案在上面:

<authentication-manager >
    <authentication-provider ref="ldapAuthProvider" />            
</authentication-manager>


<beans:bean id="contextSource"
    class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">        
<beans:constructor-arg value="ldap://IP:port/...."/>

</beans:bean>

<beans:bean id="ldapAuthProvider"
   class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
    <beans:constructor-arg>
    <beans:bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
    <beans:constructor-arg ref="contextSource"/>
    <beans:property name="userSearch" ref="ldapUserSearch" />
    </beans:bean>
    </beans:constructor-arg>
    <beans:constructor-arg>
    <beans:bean
    class="prpa.athos.security.listener.MyLDAPAuthorities">
    </beans:bean>
    </beans:constructor-arg>
    </beans:bean>
    <beans:bean id="authenticationSuccessListener"   
    class="prpa.athos.security.listener.AuthenticationSuccessListener">
    </beans:bean>        
    <beans:bean id="ldapUserSearch"   
    class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
    <beans:constructor-arg index="0" value=""/>
    <beans:constructor-arg index="1" value="(uid={0})"/>
    <beans:constructor-arg index="2" ref="contextSource" />
    </beans:bean>

在类MyLDAPAuthorities上,我实现了类LdapAuthoritiesPopulator,以从数据库中获取权限。

是的,您将需要一个LdapBindAuthenticator和一个基于DAO的AuthoritiesPopulator

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM