`

spring security 4.1两个不错功能介绍

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

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

public class WebSecurity {
		public boolean checkUserId(Authentication authentication, int id) {
				...
		}
}


则可以用这个配置进行防护
  <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
3
8
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics