• This repository has been archived on 20/Oct/2023
  • Stars
    star
    350
  • Rank 121,229 (Top 3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A totally simple and very easy to configure stand alone webdav server

Build Status Go Report

dave - The simple WebDAV server

dave is a simple WebDAV server that provides the following features:

  • 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).

The project name dave is an abbreviation for: Distributed Authoring and Versioning made easy.

Table of Contents

Configuration

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:

  • The directory ./config
  • The directory $HOME/.swd (swd was the initial project name of dave)
  • The directory $HOME/.dave
  • The current working directory .

Alternatively, the path to a configuration file can be specified on the command-line:

dave --config /path/to/config.yaml

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"

With this configuration you'll grant access for two users and the WebDAV server is available under http://127.0.0.1:8000/webdav.

TLS

At first, use your favorite toolchain to obtain a SSL certificate and keyfile (if you don't already have some).

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

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:
...

The presence of the tls section is completely enough to let the server start with a TLS secured HTTPS connection.

In the current release version you must take care, that the private key doesn't need a passphrase. Otherwise starting the server will fail.

Cross Origin Resource Sharing (CORS)

In case you intend to operate this server from a web browser based application, you might need to allow CORS access. To achieve that, you can configure the host you want to grant access to:

cors:
  origin: "*"        # the origin to allow, or '*' for all
  credentials: true  # whether to allow credentials via CORS

Note however that this has security implications, so be careful in production environments.

Behind a proxy

dave will also work behind a reverse proxy. Here is an example configuration with apache2 httpd's mod_proxy:

<Location /webdav>
  ProxyPass           https://webdav-host:8000/
  ProxyPassReverse    https://webdav-host:8000/
</Location>

User management

User management in dave is very simple, but optional. You don't have to add users if it's not necessary for your use case. But if you do, each user in the config.yaml must have a password and can have a subdirectory.

The password must be in form of a BCrypt hash. You can generate one calling the shipped cli tool davecli passwd.

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.

Logging

You can enable / disable logging for the following operations:

  • Creation of files or directories
  • Reading of files or directories
  • Updating of files or directories
  • Deletion 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:

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
...

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

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.

Installation

Binary installation

You can check out the releases page for the latest precompiled binaries.

Otherwise you can use the binary installation via go get:

go get github.com/micromata/dave/cmd/...

Build from sources

Setup

  1. Ensure you've set up Go. Take a look at the installation guide and how you set up your path
  2. Create a source directory and change your working directory
mkdir -p $GOPATH/src/github.com/micromata/ && cd $GOPATH/src/github.com/micromata
  1. Clone the repository (or your fork)
git clone https://github.com/micromata/dave.git

To build and install from sources you have two major possibilites:

go install

You can use the plain go toolchain and install the project to your $GOPATH via:

cd $GOPATH/src/github.com/micromata/dave && go install ./...

magefile

You can also use mage to build the project.

Please ensure you've got mage installed. This can be done with the following steps:

git clone https://github.com/magefile/mage
cd mage
go run bootstrap.go

The golint utility is also required for mage check:

go install golang.org/x/lint/golint

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:
  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
  install          Installs dave and davecli to your $GOPATH/bin folder
  installDeps      Runs dep ensure and installs additional dependencies.

Build and run with Docker

The image of dave is available on Docker Hub as micromata/dave.

If you like to build it for your own, just execute the following lines:

git clone https://github.com/micromata/dave.git
cd dave
docker build -t micromata/dave:latest .

You can run dave with the following lines:

# 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 \
	micromata/dave:latest

Connecting

You could simply connect to the WebDAV server with an 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 to get an idea of it.

If you'd like to contribute, please make sure to use the magefile and execute and check the following commands before starting a PR:

mage fmt
mage check

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

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 the Apache 2 License.

More Repositories

1

awesome-javascript-learning

A tiny list limited to the best JavaScript Learning Resources
5,295
star
2

awesome-css-learning

A tiny list limited to the best CSS Learning Resources
3,240
star
3

http-fake-backend

Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
JavaScript
311
star
4

Baumeister

Unmaintained – 👷 The aim of this project is to help you to build your things. From Bootstrap themes over static websites to single page applications.
SCSS
171
star
5

awesome-open-source-supporting

An awesome list about possibilities to support Open Source
115
star
6

projectforge

Java
103
star
7

cli-error-notifier

Sends native desktop notifications if CLI apps fail
JavaScript
71
star
8

projectforge-webapp

ProjectForge is a web-based solution for project management including time tracking, team-calendar, financial administration, issue management, controlling and managing work-break-down-structures (e. g. together with JIRA as issue management system).
Java
61
star
9

generator-http-fake-backend

Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
JavaScript
58
star
10

JiraRestClient

A simple Java Client for the JIRA Rest-API.
Java
55
star
11

generator-baumeister

Unmaintained – Yeoman Generator for »Baumeister«. The aim of this project is to help you to build your things. From Bootstrap themes over static websites to single page applications.
JavaScript
54
star
12

webengineering-2017

Source code, slides and miscellaneous stuff for the lecture Webengineering 2017 at the University of Kassel
Java
18
star
13

Merlin

Magic and customer-friendly Excel, Word and configuration acrobatics, including upload/download and templating.
Java
17
star
14

sawdust

Java module system and JUnit 5 tests
Java
15
star
15

borgbackup-butler

A client for a convenient handling of backups created by borg, such as restoring, listing etc.
JavaScript
15
star
16

check-packages

CLI tool to check your npm dependencies against a list of allowed/forbidden packages.
JavaScript
14
star
17

ConfluenceRestClient

A simple Java Client for the Confluence Rest-API.
Java
12
star
18

iFORP

Next Level HTML Prototyping -- https://prototyping4innovation.de/iforp
JavaScript
7
star
19

documentsearch

We build a document search engine with play!, elasticsearch and git. - conference repository
Scala
7
star
20

pdf-renderer

Node.js based renderer using Handlebars und JSON data to generate PDFs from HTML-Pages using wkhtmltopdf
JavaScript
6
star
21

hungry-fetch

Nomnomnom... lets you test your fetch calls.
TypeScript
6
star
22

webengineering-2019

Slides and code for the lecture Webengineering 2019 at the University of Kassel
Java
4
star
23

WebSecurity

WebSecurity Projekt.
JavaScript
4
star
24

baumeister.io

The website of Baumeister
CSS
4
star
25

labs-spring-security

Example code for blog articles about spring-security under https://labs.micromata.de/blog/tutorial-spring-security-uebersicht.html
Java
4
star
26

JUGH-2012-Adam-Bien

Java
4
star
27

paypal

Integration of PayPal in your Java application
Java
4
star
28

cloud-elastic-workloads

t+x^2 project demonstrating multiple approaches to automatically scale performance-critical application parts using cloud technologies
Java
4
star
29

mgc

Micromata Genome Commons
Java
4
star
30

tec-talk-spa-coding-samples

This repository contains the coding samples for the tec talk »Single Page Apps - A Framework Agnostic Approach« by René Viering
CSS
4
star
31

projectforge-excel

Excel export package (convenient usage of POI) for exporting MS-Excel sheet with a few lines of code or modifiing existing MS-Excel sheets.
Java
4
star
32

open-data-codefest

Ergebnisse des Open Data Codefest
Jupyter Notebook
3
star
33

ProFi-Pattern-Library

CSS
3
star
34

webengineering-2015-ss

Lecture material for Webengineering at the University of Kassel
3
star
35

generator-bootstrap-kickstart

[deprecated] Check the successor Baumeister instead.
JavaScript
3
star
36

xjcpluginjavaapiforkml

XJC Plugin to generate the Java API for KML.
HTML
3
star
37

es-log4j2

Log4j2-NoSQL-Appender for elasticsearch
Java
3
star
38

projectforge-continuous-db

Supports programmatically creation and updates of data-bases for continuous delivery independent of the data-base vendor. SQL-Scripts may be created manually or automatically by parsing JPA annotations with a few lines of code.
Java
3
star
39

projectforge-sync-adapter

Java
2
star
40

projectforge-common

Common used classes (by web app, standalone etc.).
Java
2
star
41

projectforge-webserver

Start helper for jetty.
Java
2
star
42

webengineering-2015-ss-demo

Source code of the live-coding demo for the lecture Webengineering.
Java
2
star
43

projectforge-jax-rs

Java API for RESTful Web Services
Java
2
star
44

spring-slim-docker-images

Example repository for slim spring docker images
Dockerfile
2
star
45

baumeister-media

Baumeister logo and artwork
PostScript
2
star
46

tpsb

TestBuilder Framework
Java
1
star
47

bootstrap-kickstart

[deprecated] Check the successor Baumeister instead.
CSS
1
star
48

raktajino

Raktajino - JUnit Extensions, served steamed or iced
Java
1
star
49

labs-website

Home of Micromata Open Source Content.
SCSS
1
star
50

eslint-config-baumeister

This package provides Baumeisters ESLint settings as an extensible shared config.
JavaScript
1
star