fix: possible fix for proxy auth requiring login page
License: MIT Signed-off-by: Henrique Dias <hacdias@gmail.com>
This commit is contained in:
@@ -10,4 +10,6 @@ import (
|
|||||||
type Auther interface {
|
type Auther interface {
|
||||||
// Auth is called to authenticate a request.
|
// Auth is called to authenticate a request.
|
||||||
Auth(r *http.Request, s *users.Storage, root string) (*users.User, error)
|
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
|
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"
|
const reCaptchaAPI = "/recaptcha/api/siteverify"
|
||||||
|
|
||||||
// ReCaptcha identifies a recaptcha conenction.
|
// 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) {
|
func (a NoAuth) Auth(r *http.Request, sto *users.Storage, root string) (*users.User, error) {
|
||||||
return sto.Get(root, uint(1))
|
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
|
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", "/")
|
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{}{
|
data := map[string]interface{}{
|
||||||
"Name": d.settings.Branding.Name,
|
"Name": d.settings.Branding.Name,
|
||||||
"DisableExternal": d.settings.Branding.DisableExternal,
|
"DisableExternal": d.settings.Branding.DisableExternal,
|
||||||
@@ -29,6 +34,7 @@ func handleWithStaticData(w http.ResponseWriter, r *http.Request, d *data, box *
|
|||||||
"StaticURL": staticURL,
|
"StaticURL": staticURL,
|
||||||
"Signup": d.settings.Signup,
|
"Signup": d.settings.Signup,
|
||||||
"NoAuth": d.settings.AuthMethod == auth.MethodNoAuth,
|
"NoAuth": d.settings.AuthMethod == auth.MethodNoAuth,
|
||||||
|
"LoginPage": auther.LoginPage(),
|
||||||
"CSS": false,
|
"CSS": false,
|
||||||
"ReCaptcha": false,
|
"ReCaptcha": false,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user