单点登出基本上没有啥配置html
直接在原来logout的时候,重定向到Cas-Server的logout方法web
@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后,最终会停留在这个页面上服务器
通常这不是咱们想要的。session
我想要的是,一旦用户登出,从新回到登陆页面。app
那么从新修改原有项目的logout方法,以下:maven
@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后,想要回到哪一个页面。spa
而后,在Cas-Server项目的cas-servlet.xml中,找到code
<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"server
意思是:成功Logout后,若是包含Service参数,则重定向到Service指定的网址。xml
单点登陆CAS使用记系列: