在版本控制节点上向 Jackrabbit 用户强制执行读写 ACL 时出现问题

发布于 2024-12-16 00:43:07 字数 3034 浏览 2 评论 0 原文

我们正在使用 Jackrabbit 2.2.7 开发 xml 文档的存储库。

我们希望为存储库创建一组用户,并对他们强制执行某种只读和读写访问权限。我们使用了基于资源的 ACL,如此处所述。只读权限就像魅力一样。然而,当用户尝试创建/删除可版本化的节点 (mix:versionable) 时,我们很难让读写工作正常进行,即使我们授予他尽可能高的权限,<代码>特权.JCR_ALL。到目前为止我们已经意识到,对版本化节点的修改实际上并不简单。在 Jackrabbit 中,它跨越多个节点 - /jcr:system/jcr:versionStorage 就是其中之一。看来除非用户本身是admin用户,否则无法对/jcr:system/及其子节点进行修改。

所以我的问题是

  • :a)有没有办法让普通用户修改版本控制节点?
  • b) 有没有办法在 jackrabbit 中创建多个管理员用户(指针、wiki、代码片段)?

以下是 repository.xml 中的安全部分:

<Security appName="Jackrabbit">
    <SecurityManager class="org.apache.jackrabbit.core.DefaultSecurityManager" 
        workspaceName="security">
        <!-- <WorkspaceAccessManager class="..."/> -->
        <!-- <param name="config" value="${rep.home}/security.xml"/> -->
    </SecurityManager>

    <AccessManager 
        class="org.apache.jackrabbit.core.security.DefaultAccessManager">
        <!-- <param name="config" value="${rep.home}/access.xml"/> -->
    </AccessManager>

    <LoginModule 
        class="org.apache.jackrabbit.core.security.authentication.DefaultLoginModule">
       <!--
          anonymous user name ('anonymous' is the default value)
        -->
       <param name="anonymousId" value="anonymous"/>
       <!--
          administrator user id (default value if param is missing is 'admin')
        -->
       <param name="adminId" value="admin"/>
    </LoginModule>
</Security>

以下是我们创建用户和启用访问控制的方式:

    {
        ...
        JackrabbitSession js = (JackrabbitSession) session;
        UserManager um = js.getUserManager();
        Authorizable grp = um.getAuthorizable("usergroup");
        Group userGroup = null;
        if(grp == null){
            userGroup = um.createGroup("usergroup");
        }else{
            userGroup = (Group) grp;
        }

        User user = um.createUser(newUserName, newUserPass);
        userGroup.addMember(user);

        Node node = session.getNode("/root");           

        AccessControlManager acm = session.getAccessControlManager();
        AccessControlList acl = getList(acm, node.getPath());

        Privilege[] privileges = null ;
        if(privilege.equals("r")){

            privileges = new Privilege[]
            {
                acm.privilegeFromName(Privilege.JCR_READ),
                acm.privilegeFromName(Privilege.JCR_LOCK_MANAGEMENT)
            };

        }else if(privilege.equals("rw")){
            privileges = new Privilege[]
            {

                acm.privilegeFromName(Privilege.JCR_ALL)
            };
        }else{

            return;
        }
        acl.addAccessControlEntry(new PrincipalImpl(user.getID()), privileges);
        acm.setPolicy(node.getPath(), acl);

        session.save();
 }

We are using Jackrabbit 2.2.7 to develop a repository for xml documents.

We want to create a bunch of users for the repository and enforce some sort of read-only and read-write access privileges on them. We have used the resource based ACL as described here. Read-only permission works as charm. However, we are having hard time getting read-write to work when a user attempts to create/delete a node that is versionable (mix:versionable), even though we grant him the highest possible privilege, Privilege.JCR_ALL. So far we have realized that the modification to a versioned node actually is not simple. In Jackrabbit, it span across multiple nodes - /jcr:system/jcr:versionStorage is one of them. It seems that unless the user is the admin user himself, he cannot make modification to /jcr:system/ and its child nodes.

So my questions are

  • a) is there a way I enable normal users to modify versionable nodes?
  • b) is there a way to create multiple admin users in jackrabbit (pointers, wiki, code snippet)?

Here is the security section from the repository.xml:

<Security appName="Jackrabbit">
    <SecurityManager class="org.apache.jackrabbit.core.DefaultSecurityManager" 
        workspaceName="security">
        <!-- <WorkspaceAccessManager class="..."/> -->
        <!-- <param name="config" value="${rep.home}/security.xml"/> -->
    </SecurityManager>

    <AccessManager 
        class="org.apache.jackrabbit.core.security.DefaultAccessManager">
        <!-- <param name="config" value="${rep.home}/access.xml"/> -->
    </AccessManager>

    <LoginModule 
        class="org.apache.jackrabbit.core.security.authentication.DefaultLoginModule">
       <!--
          anonymous user name ('anonymous' is the default value)
        -->
       <param name="anonymousId" value="anonymous"/>
       <!--
          administrator user id (default value if param is missing is 'admin')
        -->
       <param name="adminId" value="admin"/>
    </LoginModule>
</Security>

Here is how we are creating users and enabling access control:

    {
        ...
        JackrabbitSession js = (JackrabbitSession) session;
        UserManager um = js.getUserManager();
        Authorizable grp = um.getAuthorizable("usergroup");
        Group userGroup = null;
        if(grp == null){
            userGroup = um.createGroup("usergroup");
        }else{
            userGroup = (Group) grp;
        }

        User user = um.createUser(newUserName, newUserPass);
        userGroup.addMember(user);

        Node node = session.getNode("/root");           

        AccessControlManager acm = session.getAccessControlManager();
        AccessControlList acl = getList(acm, node.getPath());

        Privilege[] privileges = null ;
        if(privilege.equals("r")){

            privileges = new Privilege[]
            {
                acm.privilegeFromName(Privilege.JCR_READ),
                acm.privilegeFromName(Privilege.JCR_LOCK_MANAGEMENT)
            };

        }else if(privilege.equals("rw")){
            privileges = new Privilege[]
            {

                acm.privilegeFromName(Privilege.JCR_ALL)
            };
        }else{

            return;
        }
        acl.addAccessControlEntry(new PrincipalImpl(user.getID()), privileges);
        acm.setPolicy(node.getPath(), acl);

        session.save();
 }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夕嗳→ 2024-12-23 00:43:07

/jcr:system/jcr:versionStorage里面的内容不能直接修改。您需要使用 VersionManager< /a> 用于在版本存储中创建、删除或标记版本的接口。任何对版本控制节点具有写访问权限的用户都应该能够执行此操作,因为没有适用于版本存储的额外访问控制。

至于版本控制节点本身,请注意它们是只读。您需要显式签出版本控制节点以使其可写。

The content inside /jcr:system/jcr:versionStorage can not be directly modified. You need to use the VersionManager interface to create, remove or label versions inside the version storage. Any user with write access to the versionable node should be able to do that, as there are no extra access controls that apply to the version storage.

As for the versionable nodes themselves, note that they are read-only when checked in. You need to explicitly check out a versionable node to make it writable.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文