SSO之CAS + LDAP


本來主要詳細是介紹CAS和LDAP整合實現單點登錄的步驟。

1. 依《SSO之安裝CAS Server》所述安裝好CAS Server。
2. 安裝ApacheDS。安裝好ApacheDS后可以用Apache Directory Studio對其進行維護。需要注意的是ApacheDS端口號是10389,默認用戶uid=admin,ou=system,密碼secret
3. 建立組織架構。所有人員建立在ou=people,dc=comple,dc=com下面,第一階是部門,再下面可以是職員,也可以是子部門。

4. 打開tomcat/webapps/cas/WEB-INF/deployerConfigContext.xml,找到如下內容:

<!--
    | This is the authentication handler declaration that every CAS deployer will need to change before deploying CAS 
    | into production.  The default SimpleTestUsernamePasswordAuthenticationHandler authenticates UsernamePasswordCredentials
    | where the username equals the password.  You will need to replace this with an AuthenticationHandler that implements your
    | local authentication strategy.  You might accomplish this by coding a new such handler and declaring
    | edu.someschool.its.cas.MySpecialHandler here, or you might use one of the handlers provided in the adaptors modules.
    +-->
<bean 
    class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />

修改成如下:

<!--
<bean 
    class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />
-->
<bean class="org.jasig.cas.adaptors.ldap.BindLdapAuthenticationHandler">
    <property name="filter" value="cn=%u" />
    <property name="searchBase" value="ou=people,dc=example,dc=com" />
    <property name="contextSource" ref="contextSource" />
    <property name="allowMultipleAccounts" value="true" />
</bean>

還要在最后加上contextSource定義:

<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
    <property name="userDn" value="uid=admin,ou=system" />
    <property name="password" value="secret" />
    <property name="pooled" value="true" />
    <property name="urls">
        <list>
            <value>ldap://192.168.12.250:10389</value>
        </list>
    </property>
    <property name="baseEnvironmentProperties">
        <map>
            <entry key="java.naming.security.authentication" value="simple" />
        </map>
    </property>
</bean>

5. 將cas-server-3.5.2.1-release.zip里面的modules/cas-server-support-ldap-3.5.2.1.jar復制到cas/WEB-INF/lib。下載spring-ldap-core和spring-ldap-core-tiger到cas/WEB-INF/lib,注意對當前cas server來說,最好用1.3.2的版本。具體可以參考《Eclipse調試cas server 3.5.2.1》。

6. 重啟tomcat,登錄cas/login測試。



注意事項:
1. CAS驗證有問題時可以通過cas.log查詢一下。
2. LDAP不需要uid屬性,但一定需要userPassword屬性。

參考:
SSO之CAS+LDAP實現單點登錄認證 
SSO之CAS單點登錄實例演示
Eclipse調試cas server 3.5.2.1


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM