涉及的目录和文件
目录 | 说明 |
---|---|
services | 需要配置自定义登录的网站模版 |
static | 静态文件目录,用于存放js,css代码的 |
templates | 模板代码casLoginView.html 这个名称不可改 |
$themename.properties | 用于存放网站的模版配置信息 |
截图
service目录配置
不同的子项目下面,可能登录的风格和样式不一样,所以我们需要配置这个service目录,设定每一个子网站对应的请求样式和请求条件,如果不设定,可以指定默认样式
Apereo-10000002.json
HTTPSandIMAPS-10000001.json
这个json配置文件是系统默认的,不要修改它,只能覆盖它;
配置文件的命名必须是文件名称-id.json的这种方式,不然找不到配置文件。
参数说明
参数 | 意义 |
---|---|
@class | 模版注册的类 |
serviceId | 表示哪一个网站使用这个模板 |
name | 给这个模板命名 |
id | 模板的id |
description | 注释说明 |
evaluationOrder | 就是主题的顺序,id越小,越先匹配 |
theme | 主题名称,要和配置文件名称一致 |
attributeReleasePolicy | cas参数返回策略,这个大家现在配置不配置,无所谓了,不影响操操作 |
开启识别json文件,默认false
application.properties中
cas.serviceRegistry.initFromJson=true
模版html
from表单的内容需要遵循一定的标准th:object等等
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title th:text="${#themes.code('demo.pageTitle')}"></title>
<link rel="stylesheet" th:href="@{${#themes.code('demo.css.file')}}"/>
</head>
<body>
<h1 th:text="${#themes.code('demo.pageTitle')}"></h1>
<div>
<form method="post" th:object="${credential}">
<div th:if="${#fields.hasErrors('*')}">
<span th:each="err : ${#fields.errors('*')}" th:utext="${err}"/>
</div>
<h2 th:utext="#{screen.welcome.instructions}"></h2>
<section class="row">
<label for="username" th:utext="#{screen.welcome.label.netid}"/>
<div th:unless="${openIdLocalId}">
<input class="required"
id="username"
size="25"
tabindex="1"
type="text"
th:disabled="${guaEnabled}"
th:field="*{username}"
th:accesskey="#{screen.welcome.label.netid.accesskey}"
autocomplete="off"/>
</div>
</section>
<section class="row">
<label for="password" th:utext="#{screen.welcome.label.password}"/>
<div>
<input class="required"
type="password"
id="password"
size="25"
tabindex="2"
th:accesskey="#{screen.welcome.label.password.accesskey}"
th:field="*{password}"
autocomplete="off"/>
</div>
</section>
<section>
<input type="hidden" name="execution" th:value="${flowExecutionKey}"/>
<input type="hidden" name="_eventId" value="submit"/>
<input type="hidden" name="geolocation"/>
<input class="btn btn-submit btn-block"
name="submit"
accesskey="l"
th:value="#{screen.welcome.button.login}"
tabindex="6"
type="submit"/>
</section>
</form>
</div>
</body>
</html>
参考文章
https://blog.csdn.net/yelllowcong/article/details/79236506
https://blog.csdn.net/u010475041/article/details/78201261