Check basic auth (and set session cookie) before noauth exceptions
This enables logging in by simply making a GET request to `/` with the `Authorization` header.
This commit is contained in:
+6
-6
@@ -87,12 +87,6 @@ func basicAuthAndSessionMiddleware(cookieName string, guiCfg config.GUIConfigura
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exception for static assets and REST calls that don't require authentication.
|
|
||||||
if isNoAuthPath(r.URL.Path) {
|
|
||||||
next.ServeHTTP(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
cookie, err := r.Cookie(cookieName)
|
cookie, err := r.Cookie(cookieName)
|
||||||
if err == nil && cookie != nil {
|
if err == nil && cookie != nil {
|
||||||
sessionsMut.Lock()
|
sessionsMut.Lock()
|
||||||
@@ -111,6 +105,12 @@ func basicAuthAndSessionMiddleware(cookieName string, guiCfg config.GUIConfigura
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exception for static assets and REST calls that don't require authentication.
|
||||||
|
if isNoAuthPath(r.URL.Path) {
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Some browsers don't send the Authorization request header unless prompted by a 401 response.
|
// Some browsers don't send the Authorization request header unless prompted by a 401 response.
|
||||||
// This enables https://user:pass@localhost style URLs to keep working.
|
// This enables https://user:pass@localhost style URLs to keep working.
|
||||||
if guiCfg.SendBasicAuthPrompt {
|
if guiCfg.SendBasicAuthPrompt {
|
||||||
|
|||||||
Reference in New Issue
Block a user