【问题标题】:Spring Security - ACL readAclsById not filtering by SIDsSpring Security - ACL readAclsById 不按 SID 过滤
【发布时间】:2016-03-01 04:03:21
【问题描述】:

我正在尝试在JdbcMutableAclService 中使用 Spring Security 的 readAclsById 方法来检索由 SID 过滤的 ACL。但是,将返回不适用于传入的 SID 的 ACL。

我正在使用用户名创建 ACL 条目:

public void add(Object domainObject, String username, List<Permission> permissions) {
    MutableAcl acl;

    ObjectIdentity oid = objectIdentityRetrievalStrategy
            .getObjectIdentity(domainObject);
    Sid receipient = new PrincipalSid(username);
    try {
        acl = (MutableAcl) aclService.readAclById(oid);
    } catch (NotFoundException nfe) {
        acl = aclService.createAcl(oid);
    }
    for(Permission permission:permissions) {
        acl.insertAce(acl.getEntries().size(), permission, receipient, true);
    }
    aclService.updateAcl(acl);
}

我正在通过 Authentication 对象检索 ACL:

        List<Sid> sids = sidRetrievalStrategy.getSids(authentication);

        List<ObjectIdentity> identities = new ArrayList<>(domainObjects.size());
        for (Object domainObject : domainObjects) {
            identities.add(objectIdentityRetrievalStrategy.getObjectIdentity(domainObject));
        }

        Map<ObjectIdentity, Acl> acls = aclService.readAclsById(identities, sids);

        //see what permissions the user has for these objects
        for (Map.Entry<ObjectIdentity, Acl> entry : acls.entrySet()) {
            Acl acl = entry.getValue();
            //entries that are not applicable to the SIDs are returned    
            List<AccessControlEntry> entries = acl.getEntries();
        }

如果我登录另一个用户名并尝试通过 readAclsById 检索 ACL,我还会得到属于其他用户名的 AccessControlEntry 值。我是否正确使用了AclService

【问题讨论】:

    标签: spring-mvc spring-security spring-security-acl


    【解决方案1】:

    在对源代码进行了一番挖掘后,我找到了答案:默认实现使用BasicLookupStrategy,默认情况下会忽略 SID。

    【讨论】:

      猜你喜欢
      • 2014-11-16
      • 1970-01-01
      • 2020-07-03
      • 2019-07-18
      • 2014-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-17
      相关资源
      最近更新 更多