Apereo CAS HTML 模板似乎未加载
Apereo CAS HTML template does not seem to load
所以我使用 cas-initializr
初始化 CAS,在 cas
文件夹中使用以下命令:
curl https://casinit.herokuapp.com/starter.tgz -d "dependencies=core,bootadmin,metrics,gitsvc,jsonsvc,redis,support-themes-core" | tar -xzvf -
我的主题名称是example
。这是 cas/src/main/resources/templates
:
的文件结构
templates
├── META-INF
│ └── spring.factories
├── application.yml
├── example.properties
├── static
│ └── themes
│ └── example
│ ├── css
│ │ └── cas.css
│ ├── images
│ │ ├── favicon.ico
│ │ └── logo.png
│ └── js
│ └── cas.js
└── templates
└── example
└── casLoginView.html
casLoginView.html
的内容:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
example.properties
内容:
cas.theme.name=Example Theme
cas.theme.description=Example - Central Authentication Service
cas.standard.css.file=/themes/example/css/cas.css
cas.standard.js.file=/themes/example/js/cas.js
cas.logo.file=/themes/example/images/logo.png
cas.favicon.file=/themes/example/images/favicon.ico
cas.drawer-menu.enabled=false
cas.notifications-menu.enabled=false
cas.login-form.enabled=true
我的 cas.properties
文件位于 /etc/cas/config/
:
cas.server.name=https://localhost:8443
cas.server.prefix=${cas.server.name}/cas
cas.serviceRegistry.json.location=file:/etc/cas/services
# cas.authn.accept.enabled=false
server.ssl.key-store=file:/etc/cas/thekeystore
server.ssl.key-store-password=changeit
cas.theme.defaultThemeName=example
spring.thymeleaf.cache=false
用 ./gradlew bootRun
启动服务器后,我在 chrome 浏览器上打开了 https://localhost:8443/cas/login
。 CSS、Image 和 JS 似乎加载正常(我使用 Chrome Devtool 确认),但使用了默认模板而不是我的自定义模板。
我已经尝试谷歌搜索几个小时了,但我仍然无法弄清楚如何 cas
加载我的 html 模板。
P/s:我尝试将所有 resources
内容移动到 cas/build/resources
、cas/build/resources/main
,但它似乎也不起作用。
从 6.4 RC5 开始(这是您在撰写本文时 运行 的版本,应该在您的原始版本 post 中提供):
The collection of thymeleaf user interface template pages are no longer found in the context root of the web application resources. Instead, they are organized and grouped into logical folders for each feature category. For example, the pages that deal with login or logout functionality can now be found inside login or logout directories. The page names themselves remain unchecked. You should always cross-check the template locations with the CAS WAR Overlay and use the tooling provided by the build to locate or fetch the templates from the CAS web application context.
https://apereo.github.io/cas/development/release_notes/RC5.html#thymeleaf-user-interface-pages
请阅读发行说明并调整您的设置。
此处列出了所有模板:
https://apereo.github.io/cas/development/ux/User-Interface-Customization-Views.html#templates
所以我使用 cas-initializr
初始化 CAS,在 cas
文件夹中使用以下命令:
curl https://casinit.herokuapp.com/starter.tgz -d "dependencies=core,bootadmin,metrics,gitsvc,jsonsvc,redis,support-themes-core" | tar -xzvf -
我的主题名称是example
。这是 cas/src/main/resources/templates
:
templates
├── META-INF
│ └── spring.factories
├── application.yml
├── example.properties
├── static
│ └── themes
│ └── example
│ ├── css
│ │ └── cas.css
│ ├── images
│ │ ├── favicon.ico
│ │ └── logo.png
│ └── js
│ └── cas.js
└── templates
└── example
└── casLoginView.html
casLoginView.html
的内容:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
example.properties
内容:
cas.theme.name=Example Theme
cas.theme.description=Example - Central Authentication Service
cas.standard.css.file=/themes/example/css/cas.css
cas.standard.js.file=/themes/example/js/cas.js
cas.logo.file=/themes/example/images/logo.png
cas.favicon.file=/themes/example/images/favicon.ico
cas.drawer-menu.enabled=false
cas.notifications-menu.enabled=false
cas.login-form.enabled=true
我的 cas.properties
文件位于 /etc/cas/config/
:
cas.server.name=https://localhost:8443
cas.server.prefix=${cas.server.name}/cas
cas.serviceRegistry.json.location=file:/etc/cas/services
# cas.authn.accept.enabled=false
server.ssl.key-store=file:/etc/cas/thekeystore
server.ssl.key-store-password=changeit
cas.theme.defaultThemeName=example
spring.thymeleaf.cache=false
用 ./gradlew bootRun
启动服务器后,我在 chrome 浏览器上打开了 https://localhost:8443/cas/login
。 CSS、Image 和 JS 似乎加载正常(我使用 Chrome Devtool 确认),但使用了默认模板而不是我的自定义模板。
我已经尝试谷歌搜索几个小时了,但我仍然无法弄清楚如何 cas
加载我的 html 模板。
P/s:我尝试将所有 resources
内容移动到 cas/build/resources
、cas/build/resources/main
,但它似乎也不起作用。
从 6.4 RC5 开始(这是您在撰写本文时 运行 的版本,应该在您的原始版本 post 中提供):
The collection of thymeleaf user interface template pages are no longer found in the context root of the web application resources. Instead, they are organized and grouped into logical folders for each feature category. For example, the pages that deal with login or logout functionality can now be found inside login or logout directories. The page names themselves remain unchecked. You should always cross-check the template locations with the CAS WAR Overlay and use the tooling provided by the build to locate or fetch the templates from the CAS web application context.
https://apereo.github.io/cas/development/release_notes/RC5.html#thymeleaf-user-interface-pages
请阅读发行说明并调整您的设置。
此处列出了所有模板: https://apereo.github.io/cas/development/ux/User-Interface-Customization-Views.html#templates