首先说明一下,正常的单点登陆应该都是访问客户端,然后跳转到cas服务器验证登陆之后,返回到客户端原来的地址,
这个是通过参数service来实现的,我们返回没有客户端跳转到cas server登陆页的时候地址栏里都会跟有这个参数。这个参数就是控制重定向的。
但是如果我们直接访问server端登陆,它的这个参数是空的,所以cas给了一个默认的页面 casGenericSuccessView.jsp 所以登陆之后就跳转到这里了。
但是实际需求是通过cas server 登陆之后直接跳转到摸一个客户端,解决办法:
将要跳转的客户端url当作参数传到后台(参考https://mp.youkuaiyun.com/postedit/83744386),然后修改登陆成功之后的流程,让它做跳转即可:
修改前:
<end-state id="viewGenericLoginSuccess" view="casGenericSuccessView">
<on-entry>
<evaluate expression="genericSuccessViewAction.getAuthenticationPrincipal(flowScope.ticketGrantingTicketId)"
result="requestScope.principal"
result-type="org.jasig.cas.authentication.principal.Principal"/>
</on-entry>
</end-state>
修改后:
<end-state id="viewGenericLoginSuccess" view="externalRedirect:#{flowScope.credential.sys_url}" />
flowScope.credential.sys_url就是我们要跳转的客户端url