Creating an app that you can share folders with

This issue made me think of an app idea: https://github.com/nextcloud/server/issues/2523

Leaving the technical details aside, from a user experience point of view, I imagine an app that would provide a generic user (such as “static-bot”). Whenever a real user shares a folder with this user, the contents of the folder will be synced to a location that is publicly available.

Quick example:
User X of example.org/nextcloud wants to share a static site, consisting of a folder animalfarm with these files:
– index.html
– logo.png
– animals
–– dog.jpg
–– cat.jpg
–– cow.jpg

They put them in a folder in their nextcloud and share it with the user “static-bot” to have read permission.

Now the static site will be available at static.example.org/animalfarm.

As a bonus the user could add a file auth.txt with the content kittenlover:secret which will be translated to a Basic Authentication by the „static-bot“ and not copied to the public directory.


I know this is a very specific use case and also not the solution for the linked issue. It’s just an idea for a specific scenario that I personally could find useful. :wink: Now my question is, which prerequisites would need to be fulfilled to make this work as secure as possible. (As I read about some security concerns in the linked issue already).

My (amateurish) mind would come up with the following problems to solve:

  • I don’t know if PHP can do all that stuff. Maybe a shell-script would be easier to do the job, but then how to listen to file changes and have a simple user to share the files with? I know how I would do this stuff with rsync, but I wouldn’t know how to do it in PHP.
  • Maybe the public dir (for security reasons) shouldn’t be able to run any PHP-files, but only be able to serve static content. This requires special server configuration, but I wouldn’t mind that for this use case.
  • How would I keep the folders in sync, in case the user changes some files in the shared folder?

Well, maybe this isn’t a good idea at all. But feel free to share your thoughts on this specific use case with me :slight_smile:

2 Likes

Just a quick update on this thought:

I have found a solution that works for me, without creating a whole new app.

Diving deeper into the problem, I realized that a simple static webserver (I use a node.js server) with FTP access to the htdocs folder should suffice.

The trick is now, to mount this ftp storage as an external storage. Now you can sync and edit files directly on your webserver through nextcloud.

You can even program your webserver to require authentication of some kind.

1 Like

I like the idea, particularly around managing static websites with this method.

Though I’d prefer SFTP generally.

1 Like

There is already a global sharing available since NC12, if I didn’t get the release notes wrong? So the admin can put files/folders there and share them with e.g. certain groups and allow them again to also put stuff inside.

Yeah, amateurishly, I often use FTP as a synonym for SFTP or FTPS, if you were concerned about security :no_mouth:
Probably SFTP also might have some slight performance gains over FTPS when using as external storage?

My initial post was about sharing files with a different system. And since I thought this could be accomplished by an app, I asked for sharing with an app. The particular other system I was thinking of, is a static webserver.

Ah yeah, sorry for the misunderstanding ;).

1 Like