Basic auth: Fix #201 - broken uploads
This commit is contained in:
parent
7ca3331044
commit
773eb877bd
2
auth.go
2
auth.go
|
@ -115,7 +115,7 @@ func badAuthorizationHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if Config.siteName != "" {
|
if Config.siteName != "" {
|
||||||
rs = fmt.Sprintf(` realm="%s"`, Config.siteName)
|
rs = fmt.Sprintf(` realm="%s"`, Config.siteName)
|
||||||
}
|
}
|
||||||
w.Header().Set("WWW-Authenticate", `Basic` + rs)
|
w.Header().Set("WWW-Authenticate", `Basic`+rs)
|
||||||
}
|
}
|
||||||
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
|
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,20 +196,18 @@ func setup() *web.Mux {
|
||||||
AuthFile: Config.authFile,
|
AuthFile: Config.authFile,
|
||||||
UnauthMethods: []string{},
|
UnauthMethods: []string{},
|
||||||
}
|
}
|
||||||
okFunc := func (w http.ResponseWriter, r *http.Request) {
|
okFunc := func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Location", Config.sitePath)
|
w.Header().Set("Location", Config.sitePath)
|
||||||
w.WriteHeader(http.StatusFound)
|
w.WriteHeader(http.StatusFound)
|
||||||
}
|
}
|
||||||
authHandler := auth {
|
authHandler := auth{
|
||||||
successHandler: http.HandlerFunc(okFunc),
|
successHandler: http.HandlerFunc(okFunc),
|
||||||
failureHandler: http.HandlerFunc(badAuthorizationHandler),
|
failureHandler: http.HandlerFunc(badAuthorizationHandler),
|
||||||
authKeys: readAuthKeys(Config.authFile),
|
authKeys: readAuthKeys(Config.authFile),
|
||||||
o: options,
|
o: options,
|
||||||
}
|
}
|
||||||
mux.Head(Config.sitePath+"auth", authHandler)
|
mux.Head(Config.sitePath+"auth", authHandler)
|
||||||
mux.Head(Config.sitePath+"auth/", authHandler)
|
|
||||||
mux.Get(Config.sitePath+"auth", authHandler)
|
mux.Get(Config.sitePath+"auth", authHandler)
|
||||||
mux.Get(Config.sitePath+"auth/", authHandler)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mux.Post(Config.sitePath+"upload", uploadPostHandler)
|
mux.Post(Config.sitePath+"upload", uploadPostHandler)
|
||||||
|
|
|
@ -20,7 +20,7 @@ Dropzone.options.dropzone = {
|
||||||
dropzone.cancelUpload(file)
|
dropzone.cancelUpload(file)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.open("HEAD", "auth/", true);
|
xhr.open("HEAD", "/auth", true);
|
||||||
xhr.send()
|
xhr.send()
|
||||||
}
|
}
|
||||||
var upload = document.createElement("div");
|
var upload = document.createElement("div");
|
||||||
|
|
Loading…
Reference in New Issue