-
下載下傳 git clone -b 5.3 https://github.com/apereo/cas-overlay-template.git
控制台執行 ./build.sh package 将target下生成的cas.war包放入到tomcat的webapps中,tomcat啟動會自動解壓war包為
檔案夾,由于CAS預設使用的是基于https協定,需要改為相容使用http協定,需修改cas\WEB-INF\classes目錄的application.properties添加如下的内容
cas.tgc.secure=false
cas.serviceRegistry.initFromJson=true
\cas\WEB-INF\classes\services目錄下的HTTPSandIMAPS-10000001.json
修改内容如下,即添加http
"serviceId" : "^(https|http|imaps)://.*",
在建立的springboot項目的pom.xml添加如下依賴
<!-- https://mvnrepository.com/artifact/net.unicon.cas/cas-client-autoconfig-support -->
<dependency>
<groupId>net.unicon.cas</groupId>
<artifactId>cas-client-autoconfig-support</artifactId>
<version>1.7.0-GA</version>
</dependency>
配置
cas:
server-url-prefix: http://localhost:8080/cas
server-login-url: http://localhost:8080/cas/login
client-host-url: http://localhost:9100
validation-type: cas
server:
port: 9100
在@SpringBootApplication上添加 啟動CAS @EnableCasClient
寫一個rest接口測試
@RestController
public class TestController {
@GetMapping("/test")
public String get(){
return "test success";
}
}
相同的方式另外再建立一個springboot應用,修改配置
cas:
server-url-prefix: http://localhost:8080/cas
server-login-url: http://localhost:8080/cas/login
client-host-url: http://localhost:9200
validation-type: cas
server:
port: 9200
通路:http://localhost:9100 http://localhost:9200頁面都會跳轉到cas的登入頁,在一個視窗輸入配置的使用者名和密碼之後admin admin 在另外一個視窗重新整理,即可看到也已經登入了,看到了頁面内容
一些問題:
- 解決Tomcat8啟動時控制台中文亂碼問題
/conf/logging.properties 添加java.util.logging.ConsoleHandler.encoding = GBK
- 工具版本:
apache-tomcat-8.5.40
java version "1.8.0_152"
- cas 預設的使用者名::密碼 casuser::Mellon 添加使用者 cas.authn.accept.users=admin::admin
在cas\WEB-INF\classes目錄的application.properties
- 修改cas\WEB-INF\classes\log4j2.xml中日志檔案目錄,從cas.war解壓出來的war包中,可以看出一些配置檔案的路徑是liunx路徑,如果在windows平台部署,需要修改相應的路徑
- Bad Request This combination of host and port requires TLS.解決方法?
如果是配置相容了http就不會出現這個
參考:
https://blog.csdn.net/qq_35738369/article/details/86581029
https://github.com/apereo/cas-overlay-template/tree/5.3
https://blog.csdn.net/u010248330/article/details/70338800
CAS5.3修改為支援非http的,因為它預設是https的
https://blog.csdn.net/lhc0512/article/details/82466246
keytool分别為用戶端 服務端生成證書,讓雙方互信
https://blog.csdn.net/guanking19/article/details/90142927
Spring Boot 配置 HTTPS 通路
https://blog.csdn.net/u013360850/article/details/85493764