一、去除CAS Server的HTTPS
CAS默认是采用https模式的,我们没有配置证书,所以要么配置证书,要么取消https的过滤,让http协议也能访问;我们这里取消https的配置,让http也能访问。
需要修改三个文件四处地方的配置(针对4.0.0版本,其他版本的话第一处必改,其他的看看还有没有带有cookie的文件名),详细配置修改如下:
1、WEB-INF/deployerConfigContext.xml
<bean id="proxyAuthenticationHandler"
class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
p:httpClient-ref="httpClient" />
在以上代码处增加参数 p:requireSecure=”false” ,是否需要安全验证,即 HTTPS , false 为不采用,添加以后如下:
<bean id="proxyAuthenticationHandler"
class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
p:httpClient-ref="httpClient" p:requireSecure="false"/>
该文件还有第二处需要修改,否则会出现来回从客户端到服务端来回跳转的问题
list id="registeredServicesList">
class="org.jasig.cas.services.RegexRegisteredService"
p:id="0" p:name="HTTP and IMAP" p:description="Allows HTTP(S) and IMAP(S) protocols"
p:serviceId="^(https?|imaps?)://.*" p:evaluationOrder="10000001" />
将p:serviceId修改为:p:serviceId=”^(https?|imaps?|http?)://.*” ,另外添加 p:enabled=”true” p:allowedToProxy=”true” p:ssoEnabled=”true” ,修改完成以后如下:
list id="registeredServicesList">
class="org.jasig.cas.services.RegexRegisteredService"
p:id="0" p:name="HTTP and IMAP" p:description="Allows HTTP(S) and IMAP(S) protocols"
p:serviceId="^(https?|imaps?|http?)://.*" p:evaluationOrder="10000001" p:enabled="true" p:allowedToProxy="true" p:ssoEnabled="true" />
2、 WEB-INF/spring-configuration/ticketGrantingTicketCookieGenerator.xml
修改 p:cookieSecure=”true” 为 p:cookieSecure=” false ” , 即不需要安全 cookie,如下部分:
id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="false"
p:cookieMaxAge="-1"
p:cookieName="CASTGC"
p:cookiePath="/cas" />
3 、 WEB-INF\spring-configuration\warnCookieGenerator.xml
修改 p:cookieSecure=”true” 为 p:cookieSecure=” false ” ,即不需要安全 cookie,结果如下:
id="warnCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="false"
p:cookieMaxAge="-1"
p:cookieName="CASPRIVACY"
p:cookiePath="/cas" />
以上修改完成以后,别忘记重新tomcat.
个人微信公众号,欢迎大家关注。