diff --git a/auth/auth.go b/auth/auth.go index d0f22cd1..72dc8f41 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -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 } diff --git a/auth/json.go b/auth/json.go index 8ad9fa47..8d187750 100644 --- a/auth/json.go +++ b/auth/json.go @@ -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. diff --git a/auth/none.go b/auth/none.go index a206157f..7e47baf7 100644 --- a/auth/none.go +++ b/auth/none.go @@ -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 +} diff --git a/auth/proxy.go b/auth/proxy.go index 176b69c5..21d072c7 100644 --- a/auth/proxy.go +++ b/auth/proxy.go @@ -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 +} diff --git a/frontend b/frontend index e370fbe5..9c3f563f 160000 --- a/frontend +++ b/frontend @@ -1 +1 @@ -Subproject commit e370fbe5007c715c994fbc8716fa193d4e2dc3bb +Subproject commit 9c3f563f8352f4e752b936c0d3a5ad5ac4054025 diff --git a/http/static.go b/http/static.go index 053c7654..29239a5f 100644 --- a/http/static.go +++ b/http/static.go @@ -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, }