微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Apereo CAS HTML 模板似乎无法加载

如何解决Apereo CAS HTML 模板似乎无法加载

所以我使用 cas-initializrcas 文件夹中的以下命令初始化了 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/resourcescas/build/resources/main,但似乎也不起作用。

解决方法

从 6.4 RC5 开始(这是您在撰写本文时运行的版本,应在您的原始帖子中提供):

thymeleaf 用户界面模板页面的集合不再在 Web 应用程序资源的上下文根中找到。相反,它们被组织并分组到每个要素类别的逻辑文件夹中。例如,处理登录或注销功能的页面现在可以在登录或注销目录中找到。页面名称本身保持未选中状态。您应该始终使用 CAS WAR Overlay 交叉检查模板位置,并使用构建提供的工具从 CAS Web 应用程序上下文中定位或获取模板。

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。