一、CAS服務端搭建
1.1 CAS支持Http登錄配置
CAS默認是要https的鏈接才能登錄的,不過學習的話是可以先去掉https限制,本博客介紹的是基於Cas4.2.7的,之前改過4.0的,詳情見https://blog.csdn.net/u014427391/article/details/82083995
Cas4.2.7和4.0的修改是不一樣的,Cas4.2.7版本需要自己編譯,是基於Gradle的,不是基於Maven的,覺得麻煩可以下載4.0,因為4.0版本有提供war包,不需要自己編譯,下面介紹一下4.2.7版本,怎么支持http登錄
需要修改cas4.2.7的cas-server-webapp/WEB-INF/cas.properties,全都改為非安全的
tgc.secure=false
warn.cookie.secure=false
cas-server-webapp/resources/service/HTTPSandIMAPS-10000001.json原來的
"serviceId" : "^(https|imaps)://.*"
加上http
"serviceId" : "^(https|imaps|http)://.*"
注釋cas-server-webapp/WEB-INF/view/jsp/default/ui/casLoginView.jsp頁面中校驗是否是HTTPS協議的標簽塊
<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>
然后登錄就沒非安全提示了
1.2 CAS服務端部署運行
然后將war包丟在Tomcat的webapp里,部署啟動,默認賬號密碼casuser/Mellon,cas4.2.7的賬號密碼是寫在cas.properties里的,這個和4.0的不一樣
accept.authn.users=casuser::Mellon
登錄成功,當然在項目中,肯定不能這樣做,這個需要我們配置jdbc或者加上權限校驗等等
單點登出,鏈接是http://127.0.0.1:8080/cas/logout
1.3 支持中文登錄界面
需要修改配置,找到WEB-INF下面的cas.properties修改
##
# CAS Internationalization
#
locale.default=zh_CN
locale.param.name=locale
message.bundle.encoding=UTF-8
message.bundle.cacheseconds=180
message.bundle.fallback.systemlocale=false
message.bundle.usecode.message=true
message.bundle.basenames=classpath:custom_messages,classpath:messages