@Post Filter不使用acl和oauth spring安全性过滤返回的方法集合

时间:2016-02-25 13:32:43

标签: spring-security spring-security-acl spring-oauth2

我试图整合Oauth安全性和acl spring安全性。

而不是oauth表达式处理程序

<sec:global-method-security pre-post-annotations="enabled" proxy-target-    class="true">
<sec:expression-handler ref="oauthExpressionHandler" />
</sec:global-method-security>

我在配置

之后使用了acl表达式处理程序

http://krams915.blogspot.in/2011/01/spring-security-3-full-acl-tutorial_30.html中所述。

我能够在table中创建acl条目。但是在使用@PostFilter时,方法返回的对象不会使用acl权限进行过滤。

有人可以帮忙吗

1 个答案:

答案 0 :(得分:1)

在我的配置中,我犯了两个错误,使@PostFilter无效。

  1. 正如Denim在上面的评论中所说的那样,我通过调度程序servlet将组件扫描两次加载,并且我再次使用上下文加载器监听器加载了调度程序servlet xml。通过这种更改,我能够检测包中的注释,我在其中声明了上下文我是web应用程序模块。但在我的服务模块中,没有检测到注释。
  2. 2我的服务层中的问题是

    我的服务类如下所示,并应用了如下注释

    @Service("a")
    @Transactional    
    Class A{
    
    public List<Users> getUsers() {
    getNames();
    }
    
    @PostFilter("hasPermission(filterObject,'edit')")
     public List<Users> getNames() {
    
    }
    

    注释不会被视为两个方法都在同一个代理中可以引用

    以下网址

    Spring AOP not working for method call inside another method