You've already forked filebrowser
mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-11-26 14:25:26 +08:00
fix: possible fix for proxy auth requiring login page
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
Former-commit-id: aa32ec7e27f24aee497d3c1a6bb3cda4f3f30265 [formerly 92f1d95d44e0a1c0b8dd6d81b467829c8832acc8] [formerly d8c05dc476ae88b730547cce1e3644c69ee17278 [formerly 84f108f1c5]]
Former-commit-id: 9f766a5b8ef847569fb8f4f16540c256fa9ca92f [formerly 0b6b1e48435b3fe5819327e311f08eb179a19b3e]
Former-commit-id: 046dfa8350d2f1b4e7fb789fb026069e137437ef
This commit is contained in:
@@ -10,4 +10,6 @@ import (
|
||||
type Auther interface {
|
||||
// Auth is called to authenticate a request.
|
||||
Auth(r *http.Request, s *users.Storage, root string) (*users.User, error)
|
||||
// LoginPage indicates if this auther needs a login page.
|
||||
LoginPage() bool
|
||||
}
|
||||
|
||||
@@ -59,6 +59,11 @@ func (a JSONAuth) Auth(r *http.Request, sto *users.Storage, root string) (*users
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// LoginPage tells that json auth doesn't require a login page.
|
||||
func (a JSONAuth) LoginPage() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
const reCaptchaAPI = "/recaptcha/api/siteverify"
|
||||
|
||||
// ReCaptcha identifies a recaptcha conenction.
|
||||
|
||||
@@ -17,3 +17,8 @@ type NoAuth struct{}
|
||||
func (a NoAuth) Auth(r *http.Request, sto *users.Storage, root string) (*users.User, error) {
|
||||
return sto.Get(root, uint(1))
|
||||
}
|
||||
|
||||
// LoginPage tells that no auth doesn't require a login page.
|
||||
func (a NoAuth) LoginPage() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -27,3 +27,8 @@ func (a ProxyAuth) Auth(r *http.Request, sto *users.Storage, root string) (*user
|
||||
|
||||
return user, err
|
||||
}
|
||||
|
||||
// LoginPage tells that proxy auth doesn't require a login page.
|
||||
func (a ProxyAuth) LoginPage() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
2
frontend
2
frontend
Submodule frontend updated: e370fbe500...9c3f563f83
@@ -21,6 +21,11 @@ func handleWithStaticData(w http.ResponseWriter, r *http.Request, d *data, box *
|
||||
|
||||
staticURL := strings.TrimPrefix(d.server.BaseURL+"/static", "/")
|
||||
|
||||
auther, err := d.store.Auth.Get(d.settings.AuthMethod)
|
||||
if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
data := map[string]interface{}{
|
||||
"Name": d.settings.Branding.Name,
|
||||
"DisableExternal": d.settings.Branding.DisableExternal,
|
||||
@@ -29,6 +34,7 @@ func handleWithStaticData(w http.ResponseWriter, r *http.Request, d *data, box *
|
||||
"StaticURL": staticURL,
|
||||
"Signup": d.settings.Signup,
|
||||
"NoAuth": d.settings.AuthMethod == auth.MethodNoAuth,
|
||||
"LoginPage": auther.LoginPage(),
|
||||
"CSS": false,
|
||||
"ReCaptcha": false,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user