Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read-Only FileSystem #42

Open
MosheL opened this issue May 3, 2019 · 7 comments
Open

Read-Only FileSystem #42

MosheL opened this issue May 3, 2019 · 7 comments
Assignees

Comments

@MosheL
Copy link

MosheL commented May 3, 2019

Thanks for good product !

I am trying to make a read-only file system ,based on DotNetFileSystem but with a access list from database.
this code works (the DNFS taking the list of files from SQL, and the files from the disk).

I tried to find the Options header list, on the source code, found all the HTTP Methods.
I am trying to remove the COPY, MOVE, etc, but could not remove them, as they scan for IHandler without the option to disable it .

For now I was found this (ugly) way, but Windows is trying to update the files or create files like desktop.ini, and similar.

public async Task<Stream> CreateAsync(CancellationToken cancellationToken)        {
	throw new ArgumentException("cant write");
}

I tried also to rewrite the AddWebDav function, but its a ugly workaround.

How to implement a ReadOnly attr, so the client will recognise the status and will not try to modify/lock the files ?

@MosheL
Copy link
Author

MosheL commented May 3, 2019

just to document a better ugly way:

services.Remove(services.Where(f => f.ServiceType == typeof(FubarDev.WebDavServer.Handlers.ICopyHandler)).First());
services.Remove(services.Where(f => f.ServiceType == typeof(FubarDev.WebDavServer.Handlers.IMoveHandler )).First());
services.Remove(services.Where(f => f.ServiceType == typeof(FubarDev.WebDavServer.Handlers.IDeleteHandler)).First());
services.Remove(services.Where(f => f.ServiceType == typeof(FubarDev.WebDavServer.Handlers.IPutHandler )).First());
			

Windows still show the option to create files, but it did not try to create desktop.ini and its friends.

@fubar-coder fubar-coder self-assigned this May 3, 2019
@fubar-coder
Copy link
Collaborator

I'm not sure if this is possible, because I couldn't find out whether MKCOL, etc.. are required for WebDAV 1 compliance.

@MosheL
Copy link
Author

MosheL commented May 13, 2019

MKCOL is writing on objects, I understand right ?

thanks for all

@fubar-coder
Copy link
Collaborator

It's for creating a new collection (directory).

@fubar-coder
Copy link
Collaborator

fubar-coder commented May 13, 2019

I thought a bit about your problem. I guess the following solution would be what you really need:

  1. Remove the OptionsHandler (service IOptionsHandler)
  2. Register your own service returning only the HTTP methods that you want to allow

The allowed HTTP methods are returned in the Allow header.

EDIT: This allows returning a different Allow HTTP header per location.

@MosheL
Copy link
Author

MosheL commented May 14, 2019

nice.

Thanks !

@BrandonStudio
Copy link

Is this issue going to be solved?

I think your solution is to add a read-only implementation of IOptionsHandler. Am I right?

I'm not familiar with this. Is WebDavOptionsResult that contains Allow header? If so, is it better to use an Attribute or a property to indicate whether a filesystem is readonly?

Besides, I saw WebDavDispatcherClass1 and think this is where HTTP Allow header is set, but it seems this class is not used at all, which makes me confused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants