讓我先說這個,說我對春天不熟悉。我被扔進一個項目工作,並試圖儘快旋轉起來Spring Security LDAP - 認證用戶的問題 - 容器問題?
考慮到這一點,我試圖用Jasig的CAS和LDAP實現彈簧安全。
當我從本地LDAP加載這個設置,事情工作正常。但是,由於我已將其重定位到公司LDAP,因此Web應用程序不再有效。
目前,我可以確認此腳本已成功登錄到LDAP並驗證容器的路徑,但是在加載頁面之前出現服務器錯誤。
代碼:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sec="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" >
<bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<!-- The URL of the ldap server, along with the base path that all other ldap path will be relative to -->
<constructor-arg value="ldaps://141.161.99.74:636/dc=testing,dc=com"/>
<property name="userDn" value="uid=OdinAdmin,ou=Specials,dc=testing,dc=com" />
<property name="password" value="testpw" />
</bean>
<bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<constructor-arg>
<bean class="org.springframework.security.ldap.authentication.BindAuthenticator">
<constructor-arg ref="contextSource"/>
<property name="userSearch" ref="ldapUserSearch"/>
</bean>
</constructor-arg>
<constructor-arg ref="authoritiesPopulator" /> <!-- Populates authorities in the UserDetails object -->
<property name="userDetailsContextMapper" ref="userDetailsMapper" /> <!-- Adds OWF groups to the UserDetails object -->
</bean>
<bean id="authoritiesPopulator" class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator">
<constructor-arg ref="contextSource"/>
<constructor-arg value="ou=OdinRoles,ou=Odin,ou=Apps"/> <!-- search base for determining what roles a user has -->
<property name="groupRoleAttribute" value="cn"/>
<!-- the following properties are shown with their default values -->
<property name="rolePrefix" value="ROLE_"/>
<property name="convertToUpperCase" value="true"/>
<property name="searchSubtree" value="true"/>
</bean>
<bean id="ldapUserSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch">
<constructor-arg value="ou=people" /> <!-- search base for finding User records -->
<constructor-arg value="(uid={0})" /> <!-- filter applied to entities under the search base in order to find a given user.
this default searches for an entity with a matching uid -->
<constructor-arg ref="contextSource" />
</bean>
<!-- Custom class that goes back to the ldap database to search for OWF group records and also adds
extra attributes from the user's ldap record to the UserDetails object.
The class implementation of this will likely need to be changed out for differnt setups -->
<bean id="userDetailsMapper" class="ozone.securitysample.authentication.ldap.OWFUserDetailsContextMapper">
<constructor-arg ref="contextSource" />
<constructor-arg value="ou=OdinGroups,ou=Odin,ou=Apps" /> <!-- search base for finding OWF group membership -->
<constructor-arg value="(uniqueMember={0})" /> <!-- filter that matches only groups that have the given username listed
as a "member" attribute -->
<property name="searchSubtree" value="true"/>
</bean>
<bean id="ldapUserService" class="org.springframework.security.ldap.userdetails.LdapUserDetailsService">
<constructor-arg ref="ldapUserSearch" />
<constructor-arg ref="authoritiesPopulator" />
<property name="userDetailsMapper" ref="userDetailsMapper" />
</bean>
</beans>
我的問題是,我是不允許有在構造帶參數的值的子容器的組和角色的搜索?在我之前的版本中,所有內容都位於同一個容器中。這樣我就可以擁有包含在我的base-dn中的所有內容,並在其中引用特定的OU。 IE瀏覽器。而不是
我不確定是否會導致問題,但任何洞察力將不勝感激。謝謝!
「subcontainers」是什麼意思? - 我的這有助於:構造函數參數和屬性是1:1映射到類。所以在spring配置中,你可以做同樣的事情,但不會多或少,而不是使用java中的普通'new'命令。 – Ralph
@Ralph感謝您的回覆。在我的原始配置中,我的所有角色,組和用戶基本上處於相同的DN下。 'ou = People,dc = argusldapprod,dc = argus,dc = test,dc = edu ou = OdinRoles,dc = argusldapprod ,dc = argus,dc = test,dc = edu ou = OdinGroups,dc = argusldapprod,dc = argus,dc = test,dc = edu' 然而,組和角色在不同的子容器中: ' ou = People,dc = test,dc = edu ou = OdinGroups,ou = Odin,ou = Apps,dc = test,dc = edu ou = OdinRoles,ou = Odin,ou = Apps,dc = test,dc = edu' 我不知道Apps和Odin子容器是否導致問題。 – ev0lution37