Spring Security 3.2用户之间的数据分开

时间:2013-12-11 13:02:33

标签: java spring spring-mvc spring-security

Spring Security - Web应用程序

让两个用户拥有相同的权限 用户A 用户B

和两个Event对象

class Event {
objectId owner;
...
}

event1所有者设置为userA event2所有者设置为userB 登录用户@

可访问
http://service/event1
http://service/event2

什么被认为是保护Web应用程序的最佳方式,以便userA只能看到

http://service/event1

但不是

http://service/event2

(和其他用户相反)

目前我已经在控制器级别实现了解决方案,即获取用户执行检查并重定向到适当位置的事件列表。 我不喜欢它。

1 个答案:

答案 0 :(得分:1)

您可以检查事件的所有者ID是否与当前已验证的委托人ID相匹配。请参阅Obtaining information about the current user

然后,您可以设置一个URL模式访问规则,对事件URL(/event*)执行此检查。请参阅Expression-Based Access Control