1.導(dǎo)入依賴
implementation "org.apereo.cas:cas-server-support-json-service-registry:${project.'cas.version'}"
implementation "org.apereo.cas:cas-server-support-themes-collection:${project.'cas.version'}"
implementation "org.webjars:jquery:3.6.0"
implementation "org.webjars:bootstrap:5.0.2"
2.在resources/services/下創(chuàng)建APPA-10001.json
{
"@class" : "org.apereo.cas.services.RegexRegisteredService",
"serviceId" : "^(http|imaps)://.*",
"name" : "app1",
"id" : 10001,
"bypassApprovalPrompt": false,
"clientId": "20180901",
"clientSecret": "123456",
"theme" : "app1",
"logoutType" : "BACK_CHANNEL",
"logoutUrl" : "http://192.168.1.121:83/"
}
3.在application.yml下指定主題
# Application properties that need to be
# embedded within the web application can be included here
server:
ssl:
enabled: false #是否開(kāi)啟https
cas:
authn:
accept:
users: []
jdbc:
query[0]:
sql: SELECT * FROM sys_user WHERE user_name = ?
url: jdbc:mysql://192.168.1.222:3306/shs-door?useUnicode=true&autoReconnect=true&autoReconnectForPools=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
user: root
password: root
fieldPassword: password
driverClass: com.mysql.jdbc.Driver
password-encoder:
type: DEFAULT
encoding-algorithm: MD5
character-encoding: UTF-8
fieldExpired: expired #是否提示改密碼的字段
fieldDisabled: disabled #是否禁用用戶的字段
oauth:
access-token:
create-as-jwt: true
service-registry:
core:
init-from-json: true #app1-10001讀取配置信息
json:
location: classpath:/services #指定json配置文件地址
theme:
default-theme-name: app1
view:
template-prefixes: classpath:templates/app1
default-redirect-url: http://192.168.1.37:8881 #login和logout的默認(rèn)跳轉(zhuǎn)頁(yè)
logout:
follow-service-redirects: true #配置允許登出后跳轉(zhuǎn)到指定頁(yè)面
redirect-parameter: service
redirect-url: http://192.168.1.37:8881 #注銷(xiāo)頁(yè)
confirm-logout: false
remove-descendant-tickets: true
ticket:
tgt:
remember-me:
enabled: true
4.在resources/下創(chuàng)建app1.properties质和,記住app1要與之前配置文件里的名字保持一致
cas.theme.name=app1
cas.page.title=app1
cas.standard.css.file=/css/mycas.css
cas.standard.js.file=/js/myjs.js
5.在src/main/java/org/apereo/cas/config/下添加靜態(tài)資源映射的配置徽诲。
/**
* lanqingciel
*/
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/css/**")
.addResourceLocations("classpath:/static/css/");
registry.addResourceHandler("/js/**")
.addResourceLocations("classpath:/static/js/");
registry.addResourceHandler("/images/**")
.addResourceLocations("classpath:/static/images/");
}
}
5.靜態(tài)資源地址如下猎塞,歡迎頁(yè)名字一定要是casLoginView.html
6.效果圖: