前言
CAS預設使用的是HTTPS協定,如果使用https協定需要SSL安全證書,需要申請購買,如果不想配置https協定,本文将介紹如果去掉CAS的https協定。
關于CAS如果部署搭建,參考上一篇文章:https://blog.csdn.net/qq_15076569/article/details/83656518
進入tomcat中的cas項目中:
1)修改WEB-INF/deployerConfigContext.xml
找到
<bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler" p:httpClient-ref="httpClient"/>
增加參數p:requireSecure="false",requireSecure屬性意思為是否需要安全驗證,即HTTPS,false為不采用
<!-- Required for proxy ticket mechanism. -->
<bean id="proxyAuthenticationHandler"
class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
p:httpClient-ref="httpClient" p:requireSecure="false" />
2)修改cas的/WEB-INF/spring-configuration/ticketGrantingTicketCookieGenerator.xml找到下面配置
參數p:cookieSecure="true",同理為HTTPS驗證相關,TRUE為采用HTTPS驗證,FALSE為不采用https驗證。
參數p:cookieMaxAge="-1",是COOKIE的最大生命周期,-1為無生命周期,即隻在目前打開的視窗有效,關閉或重新打開其它視窗,仍會要求驗證。可以根據需要修改為大于0的數字,比如3600等,意思是在3600秒内,打開任意視窗,都不需要驗證。
我們這裡将cookieSecure改為false , cookieMaxAge 改為3600
<bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="false"
p:cookieMaxAge="3600"
p:cookieName="CASTGC"
p:cookiePath="/cas" />
3)修改cas的WEB-INF/spring-configuration/warnCookieGenerator.xml找到下面配置
參數修改為和上面2一緻
<bean id="warnCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="false"
p:cookieMaxAge="3600"
p:cookieName="CASPRIVACY"
p:cookiePath="/cas" />
将cookieSecure改為false , cookieMaxAge 改為3600