fix: possible fix for proxy auth requiring login page

License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
pull/676/head
Henrique Dias 2019-02-15 12:58:45 +00:00
parent 85899acae6
commit 84f108f1c5
6 changed files with 24 additions and 1 deletions

View File

@ -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
}

View File

@ -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.

View File

@ -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
}

View File

@ -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
}

@ -1 +1 @@
Subproject commit e370fbe5007c715c994fbc8716fa193d4e2dc3bb
Subproject commit 9c3f563f8352f4e752b936c0d3a5ad5ac4054025

View File

@ -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,
}