spring security 4.1两个不错功能介绍

一转眼, spring security 已经发布4.1 了,查看
了下新特性,有两个比较值得关注:


1) 可以在pathvariable形式的URL中进行保护了
  比如有个方法:


[code="java"]
public class WebSecurity {
public boolean checkUserId(Authentication authentication, int id) {
...
}
}
[/code]


则可以用这个配置进行防护
  <http>
<intercept-url pattern="/user/{userId}/**"
access="@webSecurity.checkUserId(authentication,#userId)"/>
...
</http>


  这样,凡是/user/{userId}/**这样rest形式的url,都可以调用方法进行保护了
2) 支持Content Security Policy (CSP)
   什么是CSP?W3C的Content Security Policy,简称CSP。顾名思义,这个规范与内容安全有关,主要是用来定义页面可以加载哪些资源,减少XSS的发生。


   具体参考文章:https://www.ongod.org/1149.html
http://www.html5rocks.com/en/tutorials/security/content-security-policy/


http://open.chrome.360.cn/extension_dev/contentSecurityPolicy.html

猜你喜欢

转载自blog.csdn.net/jackyrongvip/article/details/78171188