aboutsummaryrefslogtreecommitdiff
path: root/main.go
blob: cd68a4696d81b0b998069cf656fd6a6bbe7eb4e1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main

import (
	"log"
	"net/http"
)

func main() {
	log.Println("=== Starting Bagage ===")
	config := (&Config{}).LoadWithDefault().LoadWithEnv()

	log.Println(config)

	// Assemble components to handle WebDAV requests
	http.Handle(config.DavPath+"/",
		BasicAuthExtract{
			OnNotFound: NotAuthorized{},
			OnCreds: LdapPreAuth{
				WithConfig:      config,
				OnWrongPassword: NotAuthorized{},
				OnFailure:       InternalError{},
				OnCreds: S3Auth{
					WithConfig: config,
					OnFailure:  InternalError{},
					OnMinioClient: WebDav{
						WithConfig: config,
					},
				},
			},
		})

	if err := http.ListenAndServe(config.HttpListen, nil); err != nil {
		log.Fatalf("Error with WebDAV server: %v", err)
	}
}