📂 Web File Browser
Go to file
Henrique Dias eb22fd20ce
finnally doooo and close #11
2017-04-23 15:14:59 +01:00
.github update issue template 2017-04-16 09:39:09 +01:00
_embed finnally doooo and close #11 2017-04-23 15:14:59 +01:00
assets finnally doooo and close #11 2017-04-23 15:14:59 +01:00
config fix simple bug 2017-04-16 09:33:10 +01:00
file fix #75 2017-02-19 12:28:12 +00:00
frontmatter rewrite some frontmatter and editor-related stuff 2017-01-18 18:40:20 +00:00
handlers finnally doooo and close #11 2017-04-23 15:14:59 +01:00
page remove revisioning from footer\ 2017-04-16 09:44:42 +01:00
utils add comment to ErrorToHTTPCode 2016-10-31 21:26:47 +00:00
wrapper add wrapper for HEAD #85 2017-04-16 14:29:35 +01:00
.editorconfig update travis and some stuff 2017-01-03 17:06:04 +00:00
.gitignore add submodule 2017-03-25 15:58:50 +00:00
.gitmodules subtree 2017-03-25 19:41:51 +00:00
.jsbeautifyrc update 2017-03-25 18:33:25 +00:00
.travis.yml remove diff from travis 2017-03-25 20:00:12 +00:00
LICENSE.md update names- Part II 2017-04-02 20:33:42 +01:00
README.md update message 2017-04-12 15:35:55 +01:00
filemanager.go finnally doooo and close #11 2017-04-23 15:14:59 +01:00
pre-build.sh close #60; checksum not available yet 2017-04-23 14:08:38 +01:00
setup.go updates 2016-06-28 10:24:02 +01:00

README.md

filemanager - a caddy plugin

Build community Go Report Card

filemanager provides WebDAV features and a file managing interface within the specified directory and it can be used to upload, delete, preview, rename and edit your files within that directory.

It is extremely important for security reasons to cover the path of filemanager with some kind of authentication. You can use, for example, basicauth directive.

Note that if you are handling large files you might run into troubles due to the defaults of timeouts plugin. Check its documentation to learn more about that plugin.

Get Started

To start using this plugin you just need to go to the download Caddy page and choose filemanager in the directives section. For further information on how Caddy works refer to its documentation.

If you want to build it from source, consult our developers section.

Syntax

filemanager [baseurl] {
    show           directory
    webdav         [path]
    styles         filepath
    allow_new      [true|false]
    allow_edit     [true|false]
    allow_commands [true|false]
    allow_command  command
    block_command  command
    before_save    command
    after_save     command
    allow          [url|dotfiles]
    allow_r        regex
    block          [url|dotfiles]
    block_r        regex
}

All of the options above are optional.

  • baseurl is the URL where you will access the File Manager interface. Defaults to /.
  • show is the path, relative or absolute, to the directory you want to browse in. Defaults to ./.
  • webdav is the path that will be appended to baseurl in which the WebDAV will be accessible. Defaults to /webdav.
  • styles is the relative or absolute path to the stylesheet file. This file doesn't need to be accessible from the web.
  • allow_new is the permission to create new files and directories. Defaults to true.
  • allow_edit is the permission to edit, rename and delete files or directories. Defaults to true.
  • allow_commands is the permission to execute commands. Defaults to true.
  • allow_command and block_command gives, or denies, permission to execute a certain command through the admin interface. By default git, svn and hg are enabled.
  • before_save and after_save allow you to set a custom command to be executed before saving and after saving a file. The placeholder {path} can be used and it will be replaced by the file path.
  • allow and block can be used to allow or deny the access to specific files or directories using their URL. You can use the magic word dotfiles to allow or block the access to dot-files. The blocked files won't show in the admin interface. By default, block dotfiles is activated.
  • allow_r and block_r and variations of the previous options but you are able to use regular expressions with them. These regular expressions are used to match the URL, not the internal file path.

So, by default we have:

filemanager / {
    show           ./
    webdav         /webdav
    allow_new      true
    allow_edit     true
    allow_commands true
    allow_command  git
    allow_command  svn
    allow_command  hg
    block          dotfiles
}

As already mentioned, this extension should be used with basicauth. If you do that, you will also be able to set permissions for different users using the following syntax:

filemanager {
    # You set the global configurations here and
    # all the users will inherit them.
    user1:
    # Here you can set specific settings for the 'user1'.
    # They will override the global ones for this specific user.
}

Examples

Show the directory where Caddy is being executed at the root of the domain:

filemanager

Use only WebDAV:

filemanager {
    webdav /
}

Show the content of foo at the root of the domain:

filemanager {
    show foo/
}

Show the directory where Caddy is being executed at /filemanager:

filemanager /filemanager

Show the content of foo at /bar:

filemanager /bar{
    show   foo/
}

Now, a bit more complicated example. You have three users: an administrator, a manager and an editor. The administrator can do everything and has access to the commands rm and mv because he is a geeky. The manager, doesn't have access to commands, but can create and edit files. The editor can only edit files. He can't even create new ones, because he will only edit the files after the manager creates them for him. Both the editor and the manager won't have access to the financial folder. We would have:

basicauth /admin admin pass
basicauth /admin manager pass
basicauth /admin editor pass

filemanager /admin {
    show           ./
    allow_commands false
    admin:
    allow_commands true
    allow_command  rm
    allow_command  mv
    allow          dotfiles
    manager:
    block          /admin/financial
    editor:
    allow_new      false
    block          /admin/financial
}

Developers

If you want to build Caddy from source with this plugin, you should take the following steps:

  1. Download the Caddy source code (go get github.com/mholt/caddy/caddy)
  2. Download the File Manager source code (go get github.com/hacdias/caddy-filemanager).
  3. Navigate to the directory where File Manager's code is.
  4. Run go generate. Otherwise, you will get an undefined: Asset error.
  5. Navigate to the directory where Caddy's source code is and open the file caddy/caddymain/run.go.
  6. Add the line _ github.com/hacdias/caddy-filemanager to the imports section.

Now you only need to build or install Caddy and you're good to go.

Pre-commit Git Hook

go generate
git add -A

To edit CSS, JS and HTML

(In construction)