1、springsecurity和cas集成后,springsecurity的登出(本地登出)没有意义。因为本地登出后,再次访问需要授权的链接时,一样会去cas服务端进行验证,而cas服务端没有登出。会返回ticket。cas客户端再次拿着ticket去服务端校验后进行本地登录。

2、cas登出后,如果需要根据service参数跳转到指定链接。需要修改cas.properties文件配置:

cas.logout.followServiceRedirects=true

下面附上springsecurity和cas集成,完整的xml配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:security="http://www.springframework.org/schema/security"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"><!--取消对应请求路径的安全策略--><security:http pattern="/images/**" security="none"/><security:http pattern="/login/fail" security="none"/><security:http pattern="/register" security="none"/><security:http pattern="/mylogin" security="none"/><!--   entry-point-ref  入口点引用,因为原来的spring security有自己的登录入口,但是这里集成了cas,所以要使用cas的登录入口,在这里配置cas的入口点的引用 --><security:http use-expressions="false" entry-point-ref="casProcessingFilterEntryPoint"><!-- 表示要访问根目录下的所有资源,需要是ROLE_ADMIN这个角色 --><security:intercept-url pattern="/**" access="ROLE_ADMIN"/><!--配置登出地址--><security:logout logout-success-url="/images/1.png" /><!-- 关闭csrg请求 --><security:csrf disabled="true"/><!-- custom-filter为Spring security过滤器  --><!-- 因为过滤器的配置有先后之分,而spring security中也有很多内置的过滤器,而且它给每个过滤器都定义了一个别名,可以直接用别名来标识某个过滤器,如下CAS_FILTER,LOGOUT_FILTER等都是内置过滤的别名 --><!-- 这里需要自定义几个过滤器,加入spring security中,position 表示将过滤器放在指定的位置上,before表示放在指定位置之前  ,after表示放在指定的位置之后 --><security:custom-filter ref="casAuthenticationFilter"  position="CAS_FILTER" /><security:custom-filter ref="requestSingleLogoutFilter" before="LOGOUT_FILTER"/><security:custom-filter ref="singleLogoutFilter" before="CAS_FILTER"/></security:http><!-- CAS入口点 开始 ,这里就是定一个了一个CAS入口点--><bean id="casProcessingFilterEntryPoint" class="org.springframework.security.cas.web.CasAuthenticationEntryPoint"><!-- 单点登录服务器登录URL,也就是cas登录页面的访问路径 --><property name="loginUrl" value="https://jack.cn/cas/login"/><!-- 这里需要引用一个服务参数 --><property name="serviceProperties" ref="serviceProperties"/></bean><bean id="serviceProperties" class="org.springframework.security.cas.ServiceProperties"><!--service 配置自身工程的根地址+/login/cas,表示是通过自身工程跳转到cas的登录页面,/login/cas 这个是security集成cas的固定写法   --><property name="service" value="http://localhost:18086/login/cas"/></bean><!-- CAS入口点 结束 --><!-- 认证过滤器 开始 --><bean id="casAuthenticationFilter" class="org.springframework.security.cas.web.CasAuthenticationFilter"><!-- 引入一个security的认证管理器 --><property name="authenticationManager" ref="authenticationManager"/></bean><!-- 认证管理器 --><security:authentication-manager alias="authenticationManager"><!-- 引入一个 security的认证提供者--><security:authentication-provider  ref="casAuthenticationProvider"/></security:authentication-manager><!-- 认证提供者 --><bean id="casAuthenticationProvider"     class="org.springframework.security.cas.authentication.CasAuthenticationProvider"><!-- 这里是引入一个自定义的认证类,是需要自己书写,但是认证的功能交给了cas去做,可以在这个类里面根据用户名,获取security中的角色列表,要获取角色列表,才能访问上面配置的资源 --><property name="authenticationUserDetailsService"><bean class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper"><constructor-arg ref="userDetailsService" /></bean></property><!-- 这里也需要引入一个服务参数,注入自身工程的路径,表示是从那个url跳到cas的登录页面 --><property name="serviceProperties" ref="serviceProperties"/><!-- ticketValidator 为票据验证器 --><property name="ticketValidator"><bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator"><!-- 单点登录服务器cas的访问路径,用来校验票据 --><constructor-arg index="0" value="https://jack.cn/cas"/></bean></property><!-- 这个是一个固定参数 --><property name="key" value="an_id_for_this_auth_provider_only"/></bean><!-- 认证类 --><bean id="userDetailsService" class="cn.jack.service.UserDetailServiceImpl"/><!-- 认证过滤器 结束 --><!-- 这个过滤器表示对cas服务端进行单点登出 --><bean id="singleLogoutFilter" class="org.jasig.cas.client.session.SingleSignOutFilter"/><!-- 这个过滤器表示,客户端进行单点登出 --><bean id="requestSingleLogoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter"><!-- 这个配置的是cas登出的路径,后面service参数表示登出后,重定向的url,而且service参数名固定是这个 --><constructor-arg value="https://jack.cn/cas/logout?service=http://localhost:18086/images/1.png"/><constructor-arg><bean class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"/></constructor-arg><!-- 这个表示,在我们的系统中,只要请求/logout/cas,就相当于访问了上面配置的cas的登出路径 --><property name="filterProcessesUrl" value="/logout/cas"/></bean><!-- 单点登出  结束 --></beans>

cas4.2登出后,跳转指定链接相关推荐

  1. 表单提交后跳转指定链接

    表单的作用可以根据场景的变化而变化,可以是问卷调查.故障报修.自助下单等多种业务场景.如需提交后进行下一步操作,如成功提交咨询申请后自动跳转到咨询详情页,可以通过设置提交扩展,实现表单提交后跳转指定链 ...

  2. html微信自动跳转外部浏览器,外部浏览器唤起微信并跳转指定链接怎么实现?

    外部浏览器唤起微信并跳转指定链接怎么实现? 近期需要做的某个需求需要实现"外部浏览器唤起微信并跳转指定链接",看到京东和网易严选实现是用的https://open.weixin.q ...

  3. 下拉点击跳到指定链接(类同友情链接)

    html代码 <select οnchange="window.location=this.value;"><option value="#" ...

  4. js 点击 跳转到指定链接

    好的,下面是如何使用 JavaScript 实现点击跳转到指定链接的代码示例: <ahref="#" onclick="location.href='http:// ...

  5. 抖音卡片/快手/小红书/h5浏览器/微博跳转微信/qq/微信公众号/指定链接

    首先说明,本文内容及教程均转载自:抖音私信卡片系统源码搭建[图文教程]已经本人允许 功能说明: 抖音卡片跳转 微信 抖音卡片跳转 qq 抖音卡片跳转 微信公众号 抖音卡片跳转 指定网页链接 快手跳转 ...

  6. 微信如何唤起外部浏览器打开指定链接

    在我们做营销活动或推广宣传的时候,容易遇到域名被封,无法跳转app下载等情况.这时需要微信跳转外部浏览器打开页面的功能,对于微信默认可以通过:点击右上角的三点,点击"在浏览器中打开" ...

  7. Vue登录拦截 登录后继续跳转指定页面

    在开发中我们经常遇到这样的需求,需要用户登录后才可以访问该页面,如果用户没有登录点击该页面时则自动跳转到登录页面,登录后又跳转到链接的页面而不是首页,这种问题该如何去做呢? 1.在路由器router下 ...

  8. 外部浏览器唤醒APP跳转指定页面,点击返回到APP首页

    需求: 分享内容页面中有一个按钮,点击跳转到APP中的指定的某个页面,例如分享了一个文章页面,点击按钮跳转到APP的文章详情页面 页面跳转逻辑分析: 情景1:用户未安装APP,点击跳转直接跳转下载链接 ...

  9. react native 实现浏览器唤醒APP并跳转指定页面

    推荐使用react-navigation导航器提供的Deep linking 功能来实现. 根据官方的例子来一步步实现: 假设我们要实现在浏览器上通过点击URI(mychat://chat/Eric) ...

最新文章

  1. maven 命令创建多模块工程
  2. mxGraph破解说明
  3. Javascript 笔记与总结(2-6)var
  4. style 放入css文件失效_React中使用CSS的7种方式
  5. 计算1到N的十进制数中1的出现次数
  6. 遭遇DBD::mysql::dr::imp_data_size unexpectedly
  7. 可视化计算java_Java可视化计算器
  8. IE针对Ajax请求结果的缓存IE浏览器同一个请求第二次是缓存数据不刷新
  9. [c/c++] programming之路(25)、字符串(六)——memset,Unicode及宽字符,strset
  10. MySQL与MariaDB概述 (二)
  11. Windows API 进程状态信息函数
  12. spring整合atomikos实现分布式事务的方法示例_分布式事务一:基于数据库原生分布式事务方案实现...
  13. html 搜索 高亮效果,html5输入框高亮效果
  14. 一些值得注意的算法题——动态规划
  15. r语言调用python_python如何调用R
  16. 多线程NSInvocationOperation(NSOperationQueue)的基本用法
  17. windows环境上robotframework环境搭建
  18. delphi 断点调试android,Delphi 2010远程调试 - 无法使断点工作
  19. 如何实现pdf转换成cad呢?
  20. [5G学习]01-5G无线接口架构介绍

热门文章

  1. 用html js制作迷宫,JavaScript生成随机迷宫详解
  2. 今天跟linux无关--我所喜爱Linux的游戏
  3. Combined Margin loss人脸识别训练笔记
  4. 高校企业双向赋能,首届飞桨启航菁英计划圆满结束
  5. web广告推送功能开发总结
  6. Spring 配置数据库动态密码
  7. 隔空投送教程|如何将文件从iPhone或iPad空投到Mac计算机?
  8. python 妹子图抓取
  9. Centos 系统折腾
  10. 知乎80万高赞的window10壁纸