原文轉自:http://opengeek.cn/forum-viewthread-tid-151-fromuid-23.htmlhtml
CAS( Central Authentication Service)是由JA-SIG開發的一套開源的單點登陸系統,在教育行業有着很是普遍的應用,有很多企業也在使用它。CAS的特色是安全性很是高,可維護性高。下面詳細描述一下如何實現ZCS與CAS的集成。java
1.配置ZCS的CACert keystore
在zimbra用戶下執行如下腳本,將CAS的服務器證書(證書或證書鏈)導入到ZCS的CACert keystore中:
- /opt/zimbra/java/bin/keytool -import -file casserver.cert -alias cascert -trustcacerts -keystore /opt/zimbra/java/jre/lib/security/cacerts -storepass changeit
- /opt/zimbra/java/bin/keytool -import -file casserver.chain -alias caschain -trustcacerts -keystore /opt/zimbra/java/jre/lib/security/cacerts -storepass changeit
複製代碼
2.部署CAS客戶端
3.修改ZCS的配置文件
3.1 zimbra應用
將下列代碼加入到/opt/zimbra/jetty/etc/zimbra.web.xml文件中,插入位置應在<servlet>前(約230行),而後替換cas.url.com:port和 zimbra.url.com:port。
默認的端口:CAS爲8443,ZCS爲443或80。
- <filter>
- <filter-name>CasSingleSignOutFilter</filter-name>
- <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>CasSingleSignOutFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <listener>
- <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
- </listener>
- <filter>
- <filter-name>CasAuthenticationFilter</filter-name>
- <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
- <init-param>
- <param-name>casServerLoginUrl</param-name>
- <param-value>https://cas.url.com:port/cas/login</param-value>
- </init-param>
- <init-param>
- <param-name>serverName</param-name>
- <param-value>https://zimbra.url.com:port</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>CasAuthenticationFilter</filter-name>
- <url-pattern>/public/preauth.jsp</url-pattern>
- </filter-mapping>
- <filter>
- <filter-name>CasValidationFilter</filter-name>
- <filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
- <init-param>
- <param-name>casServerUrlPrefix</param-name>
- <param-value>https://cas.url.com:port/cas</param-value>
- </init-param>
- <init-param>
- <param-name>serverName</param-name>
- <param-value>https://zimbra.url.com:port</param-value>
- </init-param>
- <init-param>
- <param-name>redirectAfterValidation</param-name>
- <param-value>true</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>CasValidationFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <filter>
- <filter-name>CasHttpServletRequestWrapperFilter</filter-name>
- <filter-class>org.jasig.cas.client.util.HttpServletRequestWrapperFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>CasHttpServletRequestWrapperFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
複製代碼
3.2 zimbraAdmin應用
針對/opt/zimbra/jetty/etc/zimbraAdmin.web.xml文件進行同上一步的操做(插入內容、替換關鍵字)。
ZCS管理控制檯的默認端口是7071。
4.創建PreAuth鍵
在zimbra用戶身份下執行如下腳本:
[pre]
- zmprov gdpak yourdomain.com
複製代碼
[/pre]將會獲得這樣的PreAuth鍵值: "359d722926fc3daebd0fee5d8b9dad9bbe1646e68041afa8ab662c6a9152e6b9"。
5.創建preauth.jsp文件
5.1 zimbra應用
[li]將附件(附件爲ZIP壓縮文件,請將擴展名由GIF改成ZIP後打開)中的preauth.jsp-zimbra複製爲: /opt/zimbra/jetty/webapps/zimbra/public/preauth.jsp[/li][li]用上一步提到的 PreAuth鍵值替換其中的DOMAIN_KEY[/li][li]替換第90處的domainname.com[/li]
5.2 zimbraAdmin應用
[li]將 preauth.jsp-zimbraadmin複製爲: /opt/zimbra/jetty/webapps/zimbraAdmin/public/preauth.jsp[/li][li]用上一步提到的 PreAuth鍵值替換其中的DOMAIN_KEY[/li][li]替換第92處的domainname.com[/li]
6.替換登陸和註銷URL
以zimbra用戶身份執行如下腳本,替換ZCS默認的登陸和註銷URL:
[pre]
- zmprov md yourdomain.com zimbraWebClientLoginURL https://zimbra.url.com:port/zimbra/public/preauth.jsp
- zmprov md yourdomain.com zimbraWebClientLogoutURL https://cas.url.com:port/cas/logout
- zmprov md yourdomain.com zimbraAdminConsoleLoginURL https://zimbra.url.com:port/zimbraAdmin/public/preauth.jsp
- zmprov md yourdomain.com zimbraAdminConsoleLogoutURL https://cas.url.com:port/cas/logout
複製代碼
默認端口同前。
[/pre]
7.重啓ZCS 以zimbra身份運行zmcontrol restart命令重啓ZCS服務。