cas登錄驗證原理圖:
修改爲支持http協議:
1. 配置:cas.properties 文件
tgc.secure=false
warn.cookie.secure=false
2. 配置:${contextpath}\WEB-INF\classes\services\ HTTPSandIMAPS-10000001.json
"serviceId" : "^(https|imaps|http)://.*", // 增加 | http
3. 配置:cas目錄/WEB-INF/view/jsp/default 文件夾裏,其中ui/casLoginView.jsp爲登陸頁面。我們找到這段代碼刪掉即可。
<%--
<c:if test="${not pageContext.request.secure}">
<div id="msg" class="errors">
<h2><spring:message code="screen.nonsecure.title" /></h2>
<p><spring:message code="screen.nonsecure.message" /></p>
</div>
</c:if>
--%>
4. 輸入用戶名 casuser 密碼 Mellon 登錄成功
連接用戶數據庫配置:
1. 修改deployerConfigContext.xml,註釋掉原來的acceptUsersAuthenticationHandler配置
2. 修改deployerConfigContext.xml,新增配置
<!--begin 從數據庫中的用戶表中讀取 -->
<bean id="MD5PasswordEncoder"
class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder"
autowire="byName">
<constructor-arg value="MD5" />
</bean>
<bean id="queryDatabaseAuthenticationHandler" name="primaryAuthenticationHandler"
class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
<property name="passwordEncoder" ref="MD5PasswordEncoder" />
</bean>
<alias name="dataSource" alias="queryDatabaseDataSource"/>
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
p:driverClass="com.mysql.jdbc.Driver"
p:jdbcUrl="jdbc:mysql://172.16.30.34:3306/sso?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull"
p:user="root"
p:password="root"
p:initialPoolSize="6"
p:minPoolSize="6"
p:maxPoolSize="18"
p:maxIdleTimeExcessConnections="120"
p:checkoutTimeout="10000"
p:acquireIncrement="6"
p:acquireRetryAttempts="5"
p:acquireRetryDelay="2000"
p:idleConnectionTestPeriod="30"
p:preferredTestQuery="select 1"/>
<!--end 從數據庫中的用戶表中讀取 -->
3. 修改cas.properties,新增配置
cas.jdbc.authn.query.sql.visitor=select password from sysuser1 where username=? and isdel=0
4. 修改cas.properties,修改配置和tomcat上一致
server.name=http://localhost:8080
5. 修改cas.properties,新增配置,支持客戶端單點退出時重定向退出地址
cas.logout.followServiceRedirects:true