How to make file READ ONLY when exposed through WebDAV

为君一笑 提交于 2019-12-22 18:24:44

问题


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. Is there a way to make files/folders READ-ONLY when mounted through a WebDAV?
  2. Does WebDAV spec allows this? If so, how to do this (response format/values) on MAC and windows?

Thanks for your help.

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

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>

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

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

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


回答1:


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.

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.



来源:https://stackoverflow.com/questions/31708957/how-to-make-file-read-only-when-exposed-through-webdav

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!