나는 스프링에 정통하지 않다는 말로 이것을 서언하게한다. 나는 직장에서 프로젝트에 던져졌고 최대한 빨리 회전하려고 노력하고있다.스프링 보안 LDAP - 사용자 컨테이너 문제를 인증하는 데 문제가 있습니까?
그런 점을 염두에두고 Jasig의 CAS와 LDAP를 사용하여 스프링 보안을 구현하려고한다.
이 설정을 로컬 LDAP에서로드했을 때 문제가 없었습니다. 그러나 회사 LDAP로 이전 했으므로 webapp는 더 이상 작동하지 않습니다.
현재이 스크립트가 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>
내 질문은, 내가 그룹 및 역할 검색어 생성자, 인수 값의 하위 컨테이너를 가질 수 있습니까? 이전 버전에서는 모든 것이 동일한 컨테이너에있었습니다. 그런 식으로 저는베이스 - DN에 포함 된 모든 것을 가질 수 있으며 그 안에 특정 OU를 참조 할 수 있습니다. 예.
이 문제를 일으키는 지 확실하지 않지만 통찰력을 크게 얻었습니다. 감사!
"하위 컨테이너"는 무엇을 의미합니까? - 내 도움 : 생성자 Args 및 속성 1 : 1 클래스에 매핑됩니다. 그래서 스프링 설정에서 java의 일반적인'new' 명령보다 같거나 많을 수도 있고 적을 수도 있습니다. – Ralph
@Ralph 답장을 보내 주셔서 감사합니다. 원래의 구성에서 내 모든 역할, 그룹 및 사용자는 본질적으로 동일한 DN 아래에있었습니다. 'ou = People, dc = argusldapprod, dc = argus, dc = 테스트, dc = edu ou = OdinRoles, dc = argusldapprod 이제는 그룹과 역할이 다른 하위 컨테이너에 있습니다. 'dc = argus, dc = test, dc = edu ou = oc = test, dc = test, dc = edu ou = OdinRoles, ou = Odin, ou = Apps, dc = test, dc = edu' Apps 및 Odin 하위 컨테이너가 문제를 일으키는 지 알 수 없습니다. – ev0lution37