1
0
Fork 0
No description
Find a file
2019-08-31 16:39:50 +02:00
authdav.go initial commit 2019-08-31 16:39:50 +02:00
file.go initial commit 2019-08-31 16:39:50 +02:00
fileinfo.go initial commit 2019-08-31 16:39:50 +02:00
filesystem.go initial commit 2019-08-31 16:39:50 +02:00
go.mod initial commit 2019-08-31 16:39:50 +02:00
LICENSE initial commit 2019-08-31 16:39:50 +02:00
README.md initial commit 2019-08-31 16:39:50 +02:00

authdav - a x/net/webdav wrapper

Wrappers:

  • HTTP Basic Auth wrapper for webdav.Handler
  • write only once FileSystem wrapper for webdav.FileSystem

Usage

HTTP Basic Auth

package main

import (
	"git.giftfish.de/ston1th/authdav"
	"golang.org/x/net/webdav"
	"log"
	"net/http"
)

type exampleAuthenticator struct {}

func (exampleAuthenticator) BasicAuth(user, password string) bool {
	if user == "user" && password == "password" {
		return true
	}
	return false
}

func main() {
	auth := exampleAuthenticator{}
	handler := authdav.NewWebdavBasicAuth("", webdav.Dir("."), nil, nil, auth, "webdav with basic auth")
	log.Fatal(http.ListenAndServe(":8080", handler))
}

Write Only

package main

import (
	"git.giftfish.de/ston1th/authdav"
	"golang.org/x/net/webdav"
	"log"
	"net/http"
)

func main() {
	fs := authdav.NewWriteOnlyOnceFileSystem(webdav.Dir("."))
	handler := &webdav.Handler{
		Prefix:     "",
		FileSystem: fs,
		LockSystem: webdav.NewMemLS(),
		Logger:     nil,
	}
	log.Fatal(http.ListenAndServe(":8080", handler))
}