cas使用客户端登录界面(8)

需求:对于不同的应用系统登录界面也不一样,但是cas服务端只有一个登录界面,而且风格与客户端的应用系统很不搭边。此时我们希望可以使用客户端的登录界面(即外部界面)。下面给出一个官方的解决方案
https://wiki.jasig.org/display/CAS/Using+CAS+from+external+link+or+custom+external+form

修改cas-server.war中 ./WEB-INF\view\jsp\default\ui\casLoginView.jsp 内容如下:


...
<%@ page contentType="text/html; charset=UTF-8" %>
<%
String auto = request.getParameter("auto");
if (auto != null && auto.equals("true")) {
%>
<html>
    <head>
        <script language="javascript">
            function doAutoLogin() {
                document.forms[0].submit();
            }
        </script>
    </head>
    <body onload="doAutoLogin();">
        <form id="credentials" method="POST" action="<%= request.getContextPath() %>/login?service=<%= request.getParameter("service") %>">
            <input type="hidden" name="lt" value="${loginTicket}" />
            <input type="hidden" name="execution" value="${flowExecutionKey}" />
            <input type="hidden" name="_eventId" value="submit" />
            <input type="hidden" name="username" value="<%= request.getParameter("username") %>" />
            <input type="hidden" name="password" value="<%= request.getParameter("password") %>" />
            <% if ("true".equals(request.getParameter("rememberMe"))) {%>
                <input type="hidden" name="rememberMe" value="true" />
            <% } %>
             
            <input type="submit" value="Submit" style="visibility: hidden;" />
        </form>
    </body>
</html>
<%
} else {
%>
<jsp:directive.include file="includes/top.jsp" />
...
<jsp:directive.include file="includes/bottom.jsp" />
<%
}
%>

 

客户端:

访问方式一,直接用url访问,并提交相应的登录参数: 

https://cas.example.com/cas/loginservice=http%3A%2F%2Fapp.example.com%2Fmyapp%2F&username=myuser&password=mypass&auto=true

访问方式二:

<html>
<head />
<body>
    <form method="GET" action="https://cas.example.com/cas/">
        <p>Username : <input type="text" name="username" /></p>
        <p>Password : <input type="password" name="password" /></p>
        <p>Remember me : <input type="checkbox" name="rememberMe" value="true" /></p>
        <p><input type="submit" value="Login !" /></p>
        <input type="hidden" name="auto" value="true" />
        <input type="hidden" name="service" value="http://app.example.com/myapp/" />
    </form>
</body>
</html>

 

官网说明:

https://wiki.jasig.org/display/CAS/Using+CAS+from+external+link+or+custom+external+form

转载于:https://my.oschina.net/u/2552286/blog/860350

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值