CAS單點登入(2):cas-4.0.0-server 去掉https驗證
阿新 • • 發佈:2018-12-22
目錄
去掉https驗證
- cas預設是採用https模式的,我們沒有配置證書,所以去掉https驗證取消https的過濾,讓http協議也能訪問
- 4.0.0 版本一共需要修改三個地方
1. 修改deployerConfigContext.xml新增p:requireSecure=”false”
- 找到tomcat下
cas/WEB-INF/deployerConfigContext.xml
// 找到如下bean配置
<bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
p:httpClient-ref="httpClient"/>
// 新增引數p:requireSecure="false"
// 修改後為:
<!-- 修改為不進行安全驗證 -->
<bean id="proxyAuthenticationHandler"
class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
p:httpClient-ref="httpClient" p:requireSecure="false"/>
2. 修改ticketGrantingTicketCookieGenerator.xml修改p:cookieSecure=”false”
- 找到tomcat下
cas/WEB-INF/spring-configuration/ticketGrantingTicketCookieGenerator.xml
// 找到如下配置
<bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="true"
p:cookieMaxAge="-1"
p:cookieName="CASTGC"
p:cookiePath="/cas" />
// 修改p:cookieSecure="false"
// 修改後為:
<bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="false"
p:cookieMaxAge="-1"
p:cookieName="CASTGC"
p:cookiePath="/cas" />
3. 修改warnCookieGenerator.xml修改p:cookieSecure=”false”
- 找到tomcat下
cas/WEB-INF/spring-configuration/warnCookieGenerator.xml
// 找到如下配置
<bean id="warnCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="true"
p:cookieMaxAge="-1"
p:cookieName="CASPRIVACY"
p:cookiePath="/cas" />
// 修改p:cookieSecure="false"
// 修改後為:
<bean id="warnCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="false"
p:cookieMaxAge="-1"
p:cookieName="CASPRIVACY"
p:cookiePath="/cas" />
去掉登入頁面的提示
去掉https驗證後 保證了http訪問也能進行正常互動。但是原生的cas server頁面上的提示是不會根據設定自動消失的。只能我們手動去除。
- 找到tomcat下:apache-tomcat-8.0.52\webapps\cas\WEB-INF\view\jsp\default\ui\
casLoginView.jsp
// 找到如下程式碼 直接刪掉
<c:if test="${not pageContext.request.secure}">
<div id="msg" class="errors">
<h2>Non-secure Connection</h2>
<p>You are currently accessing CAS over a non-secure connection. Single Sign On WILL NOT WORK. In order to have single sign on work, you MUST log in over HTTPS.</p>
</div>
</c:if>