mirror of
https://github.com/restic/rest-server.git
synced 2025-12-07 09:36:13 -08:00
Merge pull request #188 from dwmunster/f-config-htpasswd
Add configurable htpasswd file location
This commit is contained in:
@@ -47,6 +47,7 @@ func init() {
|
||||
flags.StringVar(&server.TLSCert, "tls-cert", server.TLSCert, "TLS certificate path")
|
||||
flags.StringVar(&server.TLSKey, "tls-key", server.TLSKey, "TLS key path")
|
||||
flags.BoolVar(&server.NoAuth, "no-auth", server.NoAuth, "disable .htpasswd authentication")
|
||||
flags.StringVar(&server.HtpasswdPath, "htpasswd-file", server.HtpasswdPath, "location of .htpasswd file (default: \"<data directory>/.htpasswd)\"")
|
||||
flags.BoolVar(&server.NoVerifyUpload, "no-verify-upload", server.NoVerifyUpload,
|
||||
"do not verify the integrity of uploaded data. DO NOT enable unless the rest-server runs on a very low-power device")
|
||||
flags.BoolVar(&server.AppendOnly, "append-only", server.AppendOnly, "enable append only mode")
|
||||
|
||||
@@ -111,6 +111,22 @@ func TestGetHandler(t *testing.T) {
|
||||
t.Errorf("NoAuth=true: expected no error, got %v", err)
|
||||
}
|
||||
|
||||
// With NoAuth = false and custom .htpasswd
|
||||
htpFile, err := ioutil.TempFile(dir, "custom")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() {
|
||||
err := os.Remove(htpFile.Name())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
_, err = getHandler(&restserver.Server{HtpasswdPath: htpFile.Name()})
|
||||
if err != nil {
|
||||
t.Errorf("NoAuth=false with custom htpasswd: expected no error, got %v", err)
|
||||
}
|
||||
|
||||
// Create .htpasswd
|
||||
htpasswd := filepath.Join(dir, ".htpasswd")
|
||||
err = ioutil.WriteFile(htpasswd, []byte(""), 0644)
|
||||
|
||||
Reference in New Issue
Block a user