diff --git a/cmd/cc-backend/main.go b/cmd/cc-backend/main.go index e165092..e51791f 100644 --- a/cmd/cc-backend/main.go +++ b/cmd/cc-backend/main.go @@ -342,6 +342,7 @@ func main() { // Those should be mounted to this subrouter. If authentication is enabled, a middleware will prevent // any unauthenticated accesses. secured := r.PathPrefix("/").Subrouter() + if !config.Keys.DisableAuthentication { r.Handle("/login", authentication.Login( // On success: @@ -359,16 +360,17 @@ func main() { }) })).Methods(http.MethodPost) - r.Handle("/logout", authentication.Logout(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { - rw.Header().Add("Content-Type", "text/html; charset=utf-8") - rw.WriteHeader(http.StatusOK) - web.RenderTemplate(rw, "login.tmpl", &web.Page{ - Title: "Bye - ClusterCockpit", - MsgType: "alert-info", - Message: "Logout successful", - Build: buildInfo, - }) - }))).Methods(http.MethodPost) + r.Handle("/logout", authentication.Logout( + http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { + rw.Header().Add("Content-Type", "text/html; charset=utf-8") + rw.WriteHeader(http.StatusOK) + web.RenderTemplate(rw, "login.tmpl", &web.Page{ + Title: "Bye - ClusterCockpit", + MsgType: "alert-info", + Message: "Logout successful", + Build: buildInfo, + }) + }))).Methods(http.MethodPost) secured.Use(func(next http.Handler) http.Handler { return authentication.Auth( diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 77f2165..92b777b 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -168,6 +168,8 @@ func (auth *Authentication) Login( var user *schema.User if user, ok = authenticator.CanLogin(dbUser, username, rw, r); !ok { continue + } else { + log.Debugf("Can login with user %v", user) } user, err := authenticator.Login(user, rw, r)