cas sso 整合 java + php (discuz,bbs) 配置
cas 搭建準備工作:
cas-server-3.4.4
cas-client-3.2.0
apache-tomcat-6.0.14
?
去掉https認證,改成http認證
1、進入WEB-INF\spring-configuration目錄
開啟warnCookieGenerator.xml檔案
修改p:cookieSecure的值為false
2、開啟ticketGrantingTicketCookieGenerator.xml檔案
同樣修改p:cookieSecure的值為false
3、開啟WEB-INF\deployerConfigContext.xml檔案
尋找org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler
把這代碼塊修改為如下:(添加 p:requireSecure="false"? )
?
java 用戶端配置
org.jasig.cas.client.session.SingleSignOutHttpSessionListener CAS Single Sign Out Filter org.jasig.cas.client.session.SingleSignOutFilter CAS Single Sign Out Filter /* CASFilter org.jasig.cas.client.authentication.AuthenticationFilter casServerLoginUrl http://116.226.60.173:8888/cas/login serverName http://116.226.60.173:8888 CASFilter /front/member/* CASFilter /memberCenter/* CAS Validation Filter org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter casServerUrlPrefix http://116.226.60.173:8888/cas serverName http://116.226.60.173:8888 CAS Validation Filter /* CAS HttpServletRequest Wrapper Filter org.jasig.cas.client.util.HttpServletRequestWrapperFilter CAS HttpServletRequest Wrapper Filter /* CAS Assertion Thread Local Filter org.jasig.cas.client.util.AssertionThreadLocalFilter CAS Assertion Thread Local Filter /*
?
?
?
php 端配置
require_once 'CAS.php';define('CAS_SERVER_HOSTNAME', "192.168.18.8"); define('CAS_SERVER_PORT', 8888); define('CAS_SERVER_APP_NAME', "cas"); phpCAS::setDebug();phpCAS::client(CAS_VERSION_2_0, CAS_SERVER_HOSTNAME, CAS_SERVER_PORT, CAS_SERVER_APP_NAME); phpCAS::setNoCasServerValidation();phpCAS::handleLogoutRequests(); phpCAS::forceAuthentication();$username = phpCAS::getUser(); //擷取cas 服務端使用者名稱?