【发布时间】:2013-09-21 14:06:13
【问题描述】:
我正在使用 Spring Security 3.1 进行 Active Directory 身份验证,并使用本地数据库来加载权限。我看过类似的例子,但我仍然不清楚我应该使用什么。我在 spring-security.xml 中的当前设置是:
<!-- LDAP server details -->
<security:authentication-manager>
<security:authentication-provider ref="ldapActiveDirectoryAuthProvider" />
</security:authentication-manager>
<beans:bean id="ldapActiveDirectoryAuthProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
<beans:constructor-arg value="${ldap.domain}" />
<beans:constructor-arg value="${ldap.url}" />
<beans:property name="useAuthenticationRequestCredentials" value="true" />
<beans:property name="convertSubErrorCodesToExceptions" value="true" />
</beans:bean>
我有一个类,我们称之为:“BookStoreDbAuthPopulator.java”。在这个类中,我调用了这个方法:
// Load additional authorities and create an Authentication object
final List<GrantedAuthority> authorities = loadRolesFromDatabaseHere();
我还不清楚什么:“BookStoreDbAuthPopulator.java”应该实现哪个接口,以便将加载的权限从 db 添加到 UserDetails? “UserDetailsContextMapper”还是“GrantedAuthoritiesMapper”还是“AuthenticationProvider”?
基于此解决方案:Spring Security 3 Active Directory Authentication, Database Authorization “BookStoreDbAuthPopulator.java”应该实现“AuthenticationProvider”。我的疑问是我是否应该使用“BookStoreDbAuthPopulator.java”作为“ldapActiveDirectoryAuthProvider”bean 的属性?
非常感谢。
【问题讨论】:
标签: authentication spring-security active-directory spring-security-ldap