`
nesuk
  • 浏览: 167761 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

设置CAS Filter过滤某些URL

阅读更多
    公司的平台引入了CAS SSO来实现整个系统的单点登录功能,在CAS Client的web.xml中需要配置Filter来拦截外来的请求,实现单点登录、单点登出、权限认证、Ticket认证、设置用户信息等。

    其中一个系统是多点部署的,不同的点之间要通过HTTP来传输数据,Server端是用SpringMVC实现的,那么类似这种非通过页面发起的请求就需要排除在CAS的Filter之外。刚开始的思路是在FilterMapping声明时使用正则表达式,但是部署测试无效,通过Google从SOF上得知,Servlet是不支持正则的,如下说明:

No, you can't use a regex there. According to the Java Servlet Specification v2.4 (section srv.11.1), the url-path is interpreted as follows:

•A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for path mapping.
•A string beginning with a ‘*.’ prefix is used as an extension mapping.
•A string containing only the ’/’ character indicates the "default" servlet of the application. In this case the servlet path is the request URI minus the context path and the path info is null.

•All other strings are used for exact matches only.

No regexes. Not even complicated wild-cards.


    意思好像是以"/"开头的只能通过前缀过滤,以"*"开头的只能通过后缀过滤,其它字符串只能完全匹配,不支持正则,甚至是复杂的通配符。既然Servlet不支持,那只好另寻它路了。其它还能想到的方法有:
  • 1. 自定义Filter,然后引用CAS自身的Filter;
  • 2. 将传送数据的请求从MVC中剥离。

因为CAS权限验证、登入、登出的功能是分多个Filter拦截的,修改比较复杂,而且有潜在的风险。所以最后选择了写一个单独的Servlet实现接收数据的功能。






=========================================
分享到:
评论
1 楼 游其是你 2015-01-04  
博主您好,我现在就是想过滤一些链接,如果在CAS 服务端添加注册等功能,找个怎么过滤掉,还请赐教,盼回复,谢谢!

相关推荐

Global site tag (gtag.js) - Google Analytics