1. 程式人生 > >CAS統一登入認證(14): 定製自己的sso登入介面

CAS統一登入認證(14): 定製自己的sso登入介面

1. cas允許定製自己的登入介面,並繫結到某個客戶登入,不同的cas客戶可以繫結不同的登入介面:

2.  定製介面相關檔案:

/webapps/cas/WEB-INF/classes/templates/linbsoft/casLoginView.html 介面form模板
/webapps/cas/WEB-INF/classes/services/www-100000009.json   客戶應用驗證檔案
/webapps/cas/WEB-INF/classes/linbsoft.properties  定製介面配置檔案
/webapps/cas/WEB-INF/classes/static/themes/linbsoft/css/linbsoft.css  定製css檔案

以上檔案和資料夾沒有的話,就建立它

3. /webapps/cas/WEB-INF/classes/services/www-100000009.json   客戶應用驗證檔案內容

 4.  /webapps/cas/WEB-INF/classes/linbsoft.properties   定製介面配置檔案

#cas.javascript.file=/themes/linbsoft/js/cas.js
cas.standard.css.file=/css/cas.css
#自己的樣式
cas.myself.css=themes/linbsoft/css/linbsoft.css
cas.page.title=linbsoft cas form
 

5.  /webapps/cas/WEB-INF/classes/templates/linbsoft/casLoginView.html  可以根據自己需要修改風格,基本內容如下

<!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"/>
</head>
<body>
<div>
    <form method="post" th:object="${credential}">
        <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>
        <div th:if="${#fields.hasErrors('*')}">
            <span th:each="err : ${#fields.errors('*')}" th:utext="${err}"/>
        </div>
    </form>
</div>
</body>
</html>

6.訪問該sso介面

可以正常登入使用