Skip to content
Permalink
Browse files

Basic auth: Fix #201 - broken uploads

  • Loading branch information
andreimarcu committed Mar 11, 2020
1 parent 7ca3331 commit 773eb877bd02a6678599737e10c826775ecba128
Showing with 4 additions and 6 deletions.
  1. +1 −1 auth.go
  2. +2 −4 server.go
  3. +1 −1 static/js/upload.js
@@ -115,7 +115,7 @@ func badAuthorizationHandler(w http.ResponseWriter, r *http.Request) {
if 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)
}
@@ -196,20 +196,18 @@ func setup() *web.Mux {
AuthFile: Config.authFile,
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.WriteHeader(http.StatusFound)
}
authHandler := auth {
authHandler := auth{
successHandler: http.HandlerFunc(okFunc),
failureHandler: http.HandlerFunc(badAuthorizationHandler),
authKeys: readAuthKeys(Config.authFile),
o: options,
}
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.Post(Config.sitePath+"upload", uploadPostHandler)
@@ -20,7 +20,7 @@ Dropzone.options.dropzone = {
dropzone.cancelUpload(file)
}
};
xhr.open("HEAD", "auth/", true);
xhr.open("HEAD", "/auth", true);
xhr.send()
}
var upload = document.createElement("div");

0 comments on commit 773eb87

Please sign in to comment.
You can’t perform that action at this time.