CI框架配置了cas单点登录后 出现多重定向问题,怎么解决
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CI框架配置了cas单点登录后 出现多重定向问题,怎么解决相关的知识,希望对你有一定的参考价值。
参考技术A $this->load->helper('url');redirect('/login/form/', 'refresh');
通过发送HTTP头,命令客户端转向到您指定的URL。既可以指定一个完整的URL,也可以对于站内内容,指定基于网站根目录的相对URL。本函数会自动根据您的配置文件,构造出完整的URL。
可以设定第二个参数为 location 定位操作(默认)或者 refresh 刷新操作。定位操作比刷新操作执行速度快,但是在Windows服务器上有时会报错。可选的第3个参数允许你发送一个特定的HTTP请求返回码 - 举例来说这可以用来创建303请求重定向来服务于搜索引擎. 默认的请求返回码是302(临时重定向). 第3个参数 只使用于'location'重定向, 而不是用于'refresh
更多问题到问题求助专区<http://bbs.houdunwang.com/>
单点登录CAS使用记:单点登出单点注销
单点登出基本上没有啥配置
直接在原来logout的时候,重定向到Cas-Server的logout方法
@RequestSecurity @RequestMapping(value = "loginout", method = { RequestMethod.GET, RequestMethod.POST }) public String loginout(HttpSession session) { session.invalidate(); return "redirect:https://demo.testcas.com/cas-server/logout"; }
但是这样的话,logout后,最终会停留在这个页面上
一般这不是我们想要的。
我想要的是,一旦用户登出,重新回到登录页面。
那么重新修改原有项目的logout方法,如下:
@RequestSecurity @RequestMapping(value = "loginout", method = { RequestMethod.GET, RequestMethod.POST }) public String loginout(HttpSession session) { session.invalidate(); return "redirect:https://demo.testcas.com/cas-server/logout?service=https://demo.testcas.com/cas-server/login"; }
加上了一个Service后缀,并且指定了一个URL,意思是成功logout后,想要回到哪个页面。
然后,在Cas-Server项目的cas-servlet.xml中,找到
<bean id="logoutController" class="org.jasig.cas.web.LogoutController" p:centralAuthenticationService-ref="centralAuthenticationService" p:logoutView="casLogoutView" p:followServiceRedirects="true" p:warnCookieGenerator-ref="warnCookieGenerator" p:ticketGrantingTicketCookieGenerator-ref="ticketGrantingTicketCookieGenerator" />
加上这么一个属性: p:followServiceRedirects="true"
意思是:成功Logout后,如果包含Service参数,则重定向到Service指定的网址。
单点登录CAS使用记系列:
-
单点登录CAS使用记(一):前期准备以及为CAS-Server配置SSL协议
-
单点登录CAS使用记(二):部署CAS服务器以及客户端
-
单点登录CAS使用记(三):实现自定义验证用户登录
-
单点登录CAS使用记(四):为登录页面加上验证码
-
单点登录CAS使用记(五):cas-client不拦截静态资源以及无需登录的请求。
-
单点登录CAS使用记(六):单点登出、单点注销
-
单点登录CAS使用记(七):关于服务器超时以及客户端超时的分析
-
单点登录CAS使用记(八):使用maven的overlay实现无侵入的改造CAS
以上是关于CI框架配置了cas单点登录后 出现多重定向问题,怎么解决的主要内容,如果未能解决你的问题,请参考以下文章
cas单点登录后重定向次数过多问题以及调试cas-dot-net-client