通过 WebDAV 公开时如何使文件只读 [英] How to make file READ ONLY when exposed through WebDAV

查看:41
本文介绍了通过 WebDAV 公开时如何使文件只读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WebDAV 的 jackrabbit 实现.有一个用户没有文件夹的写权限.该用户可以在桌面应用程序中打开文件并进行编辑.当用户确实保存时,服务器拒绝更改,但客户端仍然有这些更改,尽管在重新安装后,这些更改将消失.所以,我正在寻找以下问题的答案:

I'm using jackrabbit implementation of WebDAV. There is a user who doesn't have write permission to a folder. That user is able to open the file in desktop applications and able to edit. When the user does save, the server is rejecting the changes but the client is still having those changes, though after the re-mount, these changes will be gone. So, I'm looking for the answers to the following questions:

  1. 有没有办法在挂载时使文件/文件夹只读WebDAV?
  2. WebDAV 规范允许这样做吗?如果是这样,如何做到这一点(响应格式/值)在 MAC 和 Windows 上?

感谢您的帮助.

使用 jackrabbit 服务器,在 Windows 本机 WebDAV 客户端上,我们可以使用属性名称 Z:Win32FileAttributes 使其工作.

With jackrabbit server, on a windows native WebDAV client, we could got it working with property name Z:Win32FileAttributes.

这是在 charles 中捕获的 PROPFIND 响应:

Here is the PROPFIND response captured in charles:

<D:response>
    <D:href>http://10.40.61.110:8080/repository/default/content/test.txt</D:href>
    <D:propstat>
        <D:prop>
            <Z:Win32FileAttributes xmlns:Z="urn:schemas-microsoft-com:">00000021</Z:Win32FileAttributes>
            <D:creationdate>2015-07-30T05:38:24Z</D:creationdate>
            <D:getetag>"11-1438238197046"</D:getetag>
            <D:lockdiscovery />
            <D:displayname>test.txt</D:displayname>
            <D:supportedlock>
                <D:lockentry>
                    <D:lockscope>
                        <D:exclusive />
                    </D:lockscope>
                    <D:locktype>
                        <D:write />
                    </D:locktype>
                </D:lockentry>
            </D:supportedlock>
            <D:getlastmodified>Thu, 30 Jul 2015 06:36:37 GMT</D:getlastmodified>
            <D:iscollection>0</D:iscollection>
            <D:getcontenttype>application/xml</D:getcontenttype>
            <D:getcontentlength>11</D:getcontentlength>
            <D:resourcetype />
        </D:prop>
        <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
</D:response>
<D:response>
    <D:href>http://10.40.61.110:8080/repository/default/content/Desert.jpg</D:href>
    <D:propstat>
        <D:prop>
            <D:creationdate>2015-07-30T09:49:31Z</D:creationdate>
            <D:getetag>"329032-1438249785205"</D:getetag>
            <D:getlastmodified>Thu, 30 Jul 2015 09:49:45 GMT</D:getlastmodified>
            <D:iscollection>0</D:iscollection>
            <Z:Win32LastModifiedTime xmlns:Z="urn:schemas-microsoft-com:">Thu, 30 Jul 2015 09:49:45 GMT</Z:Win32LastModifiedTime>
            <Z:Win32LastAccessTime xmlns:Z="urn:schemas-microsoft-com:">Thu, 30 Jul 2015 09:49:32 GMT</Z:Win32LastAccessTime>
            <D:getcontentlength>329032</D:getcontentlength>
            <D:resourcetype />
            <Z:Win32FileAttributes xmlns:Z="urn:schemas-microsoft-com:">00000020</Z:Win32FileAttributes>
            <D:lockdiscovery />
            <D:displayname>Desert.jpg</D:displayname>
            <D:supportedlock>
                <D:lockentry>
                    <D:lockscope>
                        <D:exclusive />
                    </D:lockscope>
                    <D:locktype>
                        <D:write />
                    </D:locktype>
                </D:lockentry>
            </D:supportedlock>
            <D:getcontenttype>image/jpeg</D:getcontenttype>
            <Z:Win32CreationTime xmlns:Z="urn:schemas-microsoft-com:">Thu, 30 Jul 2015 09:49:32 GMT</Z:Win32CreationTime>
        </D:prop>
        <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
</D:response>

Z:Win32FileAttributes 的值:00000020 - 允许读/写

The value: 00000020 for Z:Win32FileAttributes - Allows to read/write

Z:Win32FileAttributes 的值:00000021 - 允许只读

The value: 00000021 for Z:Win32FileAttributes - Allows to READ-ONLY

是否也在寻找本机 MAC WebDAV 客户端的任何此类属性?

Looking for any such properties for native MAC WebDAV client as well?

推荐答案

WebDAV 使用 RFC3744 进行访问控制.通常,当用户尝试不允许的操作时,实现 RFC3744 的 WebDAV 服务器将响应 403 Forbidden http 状态代码.

WebDAV uses RFC3744 for access control. Generally when a user tries an operation that's not allowed, a WebDAV server implementing RFC3744 will respond with a 403 Forbidden http status code.

然而,大多数 WebDAV 客户端忽略了这一点,并假装整个服务器要么是可读写的,要么是只读的.某些客户端可能会发出专有的 webdav 属性来指示只读状态.例如,Windows/Office 有自己的专用属性,但我不知道 ottomh 的名称或值.

However, most WebDAV clients ignore this and pretend that the entire server is either read-write or read-only. It's possible for some clients to emit proprietary webdav properties to indicate read-only status. Windows/Office for instance have their own specialized property, but I don't know the name or value ottomh.

这篇关于通过 WebDAV 公开时如何使文件只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆