dave/Readme.md

261 lines
8.8 KiB
Markdown
Raw Normal View History

2018-05-12 22:10:51 +02:00
[![Build Status](https://travis-ci.org/micromata/dave.svg?branch=master)](https://travis-ci.org/micromata/dave)
[![Go Report](https://goreportcard.com/badge/github.com/micromata/dave)](https://goreportcard.com/report/github.com/micromata/dave)
2018-04-13 13:03:04 +02:00
2018-05-12 22:10:51 +02:00
# dave - The simple webdav server
2018-04-12 21:17:29 +02:00
2018-05-12 22:10:51 +02:00
_dave_ is a simple webdav server that provides the following features:
2018-04-12 21:17:29 +02:00
- Single binary that runs under Windows, Linux and OSX.
- Authentication via HTTP-Basic.
- TLS support - if needed.
- A simple user management which allows user-directory-jails as well as full admin access to all subdirectories.
- Live config reload to allow editing of users without downtime.
- A cli tool to generate BCrypt password hashes.
It perfectly fits if you would like to give some people the possibility to upload, download or share files with common tools like the OSX Finder, Windows Explorer or Nautilus under Linux ([or many other tools](https://en.wikipedia.org/wiki/Comparison_of_WebDAV_software#WebDAV_clients)).
2018-05-12 22:10:51 +02:00
The project name _dave_ is an abbreviation for: **D**istributed **A**uthoring and **V**ersioning made **e**asy.
2018-04-12 21:17:29 +02:00
## Table of Contents
- [Configuration](#configuration)
* [First steps](#first-steps)
* [TLS](#tls)
2018-04-13 13:20:45 +02:00
* [Behind a proxy](#behind-a-proxy)
2018-04-12 21:17:29 +02:00
* [User management](#user-management)
* [Logging](#logging)
2018-04-12 21:17:29 +02:00
* [Live reload](#live-reload)
- [Installation](#installation)
* [Binary-Installation](#binary-installation)
* [Build from sources](#build-from-sources)
2018-05-18 21:11:15 +02:00
* [Build and run with Docker](#build-and-run-with-docker)
2018-04-12 21:17:29 +02:00
- [Connecting](#connecting)
- [Contributing](#contributing)
- [License](#license)
## Configuration
2018-05-18 19:36:30 +02:00
The configuration is done in form of a yaml file. _dave_ will scan the
following locations for the presence of a `config.yaml` in the following
order:
2018-04-12 21:17:29 +02:00
- The directory `./config`
2018-05-12 22:10:51 +02:00
- The directory `$HOME/.swd` (swd was the initial project name of dave)
- The directory `$HOME/.dave`
2018-04-12 21:17:29 +02:00
- The current working directory `.`
### First steps
Here an example of a very simple but functional configuration:
address: "127.0.0.1" # the bind address
port: "8000" # the listening port
dir: "/home/webdav" # the provided base dir
prefix: "/webdav" # the url-prefix of the original url
users:
user: # with password 'foo' and jailed access to '/home/webdav/user'
password: "$2a$10$yITzSSNJZAdDZs8iVBQzkuZCzZ49PyjTiPIrmBUKUpB0pwX7eySvW"
subdir: "/user"
admin: # with password 'foo' and access to '/home/webdav'
password: "$2a$10$DaWhagZaxWnWAOXY0a55.eaYccgtMOL3lGlqI3spqIBGyM0MD.EN6"
2018-04-12 21:17:29 +02:00
With this configuration you'll grant access for two users and the webdav
server is available under `http://127.0.0.1:8000/webdav`.
2018-04-12 21:17:29 +02:00
### TLS
At first, use your favorite toolchain to obtain a SSL certificate and
keyfile (if you don't already have some).
2018-04-12 21:17:29 +02:00
Here an example with `openssl`:
# Generate a keypair
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365
# Remove the passphrase from the key file
openssl rsa -in key.pem -out clean_key.pem
2018-04-12 21:17:29 +02:00
Now you can reference your keypair in the configuration via:
address: "127.0.0.1" # the bind address
port: "8000" # the listening port
dir: "/home/webdav" # the provided base directory
tls:
keyFile: clean_key.pem
certFile: cert.pem
users:
...
2018-04-13 13:03:04 +02:00
The presence of the `tls` section is completely enough to let the server
start with a TLS secured https connection.
2018-04-12 21:17:29 +02:00
In the current release version you must take care, that the private key
doesn't need a passphrase. Otherwise starting the server will fail.
2018-04-12 21:17:29 +02:00
2018-04-13 13:20:45 +02:00
### Behind a proxy
2018-05-18 19:36:30 +02:00
_dave_ will also work behind a reverse proxy. Here is an example
configuration with `apache2 httpd`'s `mod_proxy`:
2018-04-13 13:20:45 +02:00
<Location /webdav>
ProxyPass https://webdav-host:8000/
ProxyPassReverse https://webdav-host:8000/
</Location>
2018-04-13 13:20:45 +02:00
2018-04-12 21:17:29 +02:00
### User management
2018-05-12 22:10:51 +02:00
User management in _dave_ is very simple. Each user in the `config.yaml` MUST have a password and CAN have a subdirectory.
2018-04-12 21:17:29 +02:00
2018-05-18 19:36:30 +02:00
The password must be in form of a BCrypt hash. You can generate one calling the shipped cli tool `davecli passwd`.
2018-04-12 21:17:29 +02:00
2018-04-13 13:23:57 +02:00
If a subdirectory is configured for a user, the user is jailed within it and can't see anything that exists outside of this directory. If no subdirectory is configured for an user, the user can see and modify all files within the base directory.
2018-04-12 21:17:29 +02:00
### Logging
You can enable / disable logging for the following operations:
- **C**reation of files or directories
- **R**eading of files or directories
- **U**pdating of files or directories
- **D**eletion of files or directories
You can also enable or disable the error log.
All file-operation logs are disabled per default until you will turn it on via the following config entries:
```yaml
address: "127.0.0.1" # the bind address
port: "8000" # the listening port
dir: "/home/webdav" # the provided base directory
log:
error: true
create: true
read: true
update: true
delete: true
...
```
2018-04-12 21:17:29 +02:00
Be aware, that the log pattern of an attached tty differs from the log pattern of a detached tty.
Example of an attached tty:
INFO[0000] Server is starting and listening address=0.0.0.0 port=8000 security=none
Example of a detached tty:
time="2018-04-14T20:46:00+02:00" level=info msg="Server is starting and listening" address=0.0.0.0 port=8000 security=none
### Live reload
2018-04-12 21:17:29 +02:00
There is no need to restart the server itself, if you're editing the user or log section of the configuration. The config file will be re-read and the application will update it's own configuration silently in background.
2018-04-12 21:17:29 +02:00
## Installation
### Binary installation
2018-05-12 22:10:51 +02:00
You can check out the [releases page](https://github.com/micromata/dave/releases) for the latest precompiled binaries.
2018-04-12 21:17:29 +02:00
Otherwise you can use the binary installation via go get:
```
go get github.com/micromata/dave/cmd/...
```
2018-05-12 21:50:15 +02:00
### Build from sources
2018-04-12 21:17:29 +02:00
2018-04-23 14:59:11 +02:00
#### Setup
2018-04-12 21:17:29 +02:00
2018-04-23 14:59:11 +02:00
1. Ensure you've setup _go_ Take a look at the [installation guide](https://golang.org/doc/install) and how you [setup your path](https://github.com/golang/go/wiki/SettingGOPATH)
2. Create a source directory and change your working directory
```
mkdir -p $GOPATH/src/github.com/micromata/ && cd $GOPATH/src/github.com/micromata
```
3. Clone the repository (or your fork)
```
2018-05-12 22:10:51 +02:00
git clone git@github.com:micromata/dave.git
2018-04-23 14:59:11 +02:00
```
2018-04-12 21:17:29 +02:00
To build and install from sources you have two major possibilites:
#### go install
2018-05-12 21:50:15 +02:00
You can use the plain go toolchain and install the project to your `$GOPATH` via:
2018-04-23 14:59:11 +02:00
```
2018-05-12 22:10:51 +02:00
cd $GOPATH/src/github.com/micromata/dave && go install ./...
2018-04-23 14:59:11 +02:00
```
2018-04-12 21:17:29 +02:00
#### magefile
2018-04-13 13:03:04 +02:00
You can also use mage to build the project.
2018-04-12 21:17:29 +02:00
Please ensure you've got [mage](https://magefile.org) installed. This can be done with the following steps:
go get -u -d github.com/magefile/mage
cd $GOPATH/src/github.com/magefile/mage
go run bootstrap.go
2018-04-12 21:17:29 +02:00
Now you can call `mage install` to build and install the binaries. If you just call `mage`, you'll get a list of possible targets:
Targets:
2018-05-12 22:10:51 +02:00
build Builds dave and davecli and moves it to the dist directory
buildReleases Builds dave and davecli for different OS and package them to a zip file for each os
check Runs golint and go tool vet on each .go file.
clean Removes the dist directory
fmt Formats the code via gofmt
2018-05-12 22:10:51 +02:00
install Installs dave and davecli to your $GOPATH/bin folder
installDeps Runs dep ensure and installs additional dependencies.
2018-04-12 21:17:29 +02:00
2018-05-18 20:55:58 +02:00
### Build and run with Docker
Building dave with Docker is simple
git clone git@github.com:micromata/dave.git
cd dave
docker build -t dave .
Let dave run
# create webdav home
mkdir webdav-home
docker run -d \
-p 8000:8000 \
-v $(pwd)/examples/config-sample.yaml:/config.yaml:ro \
-v $(pwd)/webdav-home:/tmp:rw \
dave
To export the static binary simply run
docker run --rm --entrypoint="" dave cat /usr/local/bin/dave > dave
chmod u+x dave
2018-04-12 21:17:29 +02:00
## Connecting
You could simply connect to the webdav server with a http(s) connection and a tool that allows the webdav protocol.
For example: Under OSX you can use the default file management tool *Finder*. Press _CMD+K_, enter the server address (e.g. `http://localhost:8000`) and choose connect.
## Contributing
Everyone is welcome to create pull requests for this project. If you're
new to github, take a look [here](https://help.github.com/categories/collaborating-with-issues-and-pull-requests/)
to get an idea of it.
If you'd like to contribute, please make sure to use the [magefile](#magefile) and execute and check the following commands before starting a PR:
mage fmt
mage check
2018-04-12 21:17:29 +02:00
If you've got an idea of a function that should find it's way into this
project, but you won't implement it by yourself, please create a new
issue.
## License
2018-04-13 13:03:04 +02:00
Please be aware of the licenses of the components we use in this project. Everything else that has been developed by the contributions to this project is under [Apache 2 License](LICENSE.txt).