Don't change realm between auth requests
This commit is contained in:
parent
d4fd18bff3
commit
299140dab1
2
api.go
2
api.go
@ -57,7 +57,7 @@ func (a apiHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
if f.AuthFunction(user, sURL[1:]) {
|
if f.AuthFunction(user, sURL[1:]) {
|
||||||
ret, err = f.DispatchFunction(user, sURL[1:], r.Body)
|
ret, err = f.DispatchFunction(user, sURL[1:], r.Body)
|
||||||
} else {
|
} else {
|
||||||
w.Header().Set("WWW-Authenticate", "Basic realm=\"YouP0m API\"")
|
w.Header().Set("WWW-Authenticate", "Basic realm=\"YouP0m\"")
|
||||||
http.Error(w, "{errmsg:\"You are not allowed to do this request.\"}", http.StatusUnauthorized)
|
http.Error(w, "{errmsg:\"You are not allowed to do this request.\"}", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
2
main.go
2
main.go
@ -93,7 +93,7 @@ func main() {
|
|||||||
|
|
||||||
mux.HandleFunc("/admin/", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/admin/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
if authFunc(r) == nil {
|
if authFunc(r) == nil {
|
||||||
w.Header().Set("WWW-Authenticate", "Basic realm=\"YouP0m Admin\"")
|
w.Header().Set("WWW-Authenticate", "Basic realm=\"YouP0m\"")
|
||||||
http.Error(w, "You are not allowed to perform this request.", http.StatusUnauthorized)
|
http.Error(w, "You are not allowed to perform this request.", http.StatusUnauthorized)
|
||||||
} else {
|
} else {
|
||||||
http.ServeFile(w, r, filepath.Join(staticDir, "admin.html"))
|
http.ServeFile(w, r, filepath.Join(staticDir, "admin.html"))
|
||||||
|
Loading…
Reference in New Issue
Block a user