【问题标题】:How to make file READ ONLY when exposed through WebDAV通过 WebDAV 公开时如何使文件只读
【发布时间】:2015-10-20 22:28:09
【问题描述】:

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

  1. 有没有办法让文件/文件夹在通过 一个WebDAV?
  2. WebDAV 规范是否允许这样做?如果是这样,如何做到这一点 (响应格式/值)在 MAC 和 Windows 上?

感谢您的帮助。

使用 jackrabbit 服务器,在 Windows 原生 WebDAV 客户端上,我们可以使用属性名称 Z:Win32FileAttributes。

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

<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 - 允许读/写

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

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

【问题讨论】:

    标签: webdav jackrabbit


    【解决方案1】:

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

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

    【讨论】:

    • 感谢@Evert 的回复。是否有文档可以支持“但是,大多数 WebDAV 客户端会忽略这一点,并假装整个服务器是读写的或只读的”。 MAC 原生 WebDAV 客户端是否有这种行为?
    • 是的,mac 客户端也有这种行为。没有文件,只是我的经验。不过,您可以轻松地自己尝试一下。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-26
    • 2018-09-10
    • 2023-04-05
    相关资源
    最近更新 更多