From 3d82cdc0ff0389039c9767c45cc7ae0bcf901cae Mon Sep 17 00:00:00 2001 From: Javier Marcos <1271349+javuto@users.noreply.github.com> Date: Mon, 8 Apr 2024 00:49:17 +0200 Subject: [PATCH] Login and logout flows for SAML --- admin/main.go | 10 +++++----- admin/static/js/login.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/admin/main.go b/admin/main.go index ccf8fcf8..1108ff70 100644 --- a/admin/main.go +++ b/admin/main.go @@ -766,8 +766,9 @@ func osctrlAdminService() { // login routerAdmin.HandleFunc(loginPath, handlersAdmin.LoginHandler).Methods("GET") routerAdmin.HandleFunc(loginPath, handlersAdmin.LoginPOSTHandler).Methods("POST") - // logout - routerAdmin.Handle(logoutPath, handlerAuthCheck(http.HandlerFunc(handlersAdmin.LogoutPOSTHandler))).Methods("POST") + routerAdmin.HandleFunc(logoutPath, func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, loginPath, http.StatusFound) + }).Methods("GET") } // Admin: health of service routerAdmin.HandleFunc(healthPath, handlersAdmin.HealthHandler).Methods("GET") @@ -864,6 +865,8 @@ func osctrlAdminService() { // edit profile routerAdmin.Handle("/profile", handlerAuthCheck(http.HandlerFunc(handlersAdmin.EditProfileGETHandler))).Methods("GET") routerAdmin.Handle("/profile", handlerAuthCheck(http.HandlerFunc(handlersAdmin.EditProfilePOSTHandler))).Methods("POST") + // logout + routerAdmin.Handle(logoutPath, handlerAuthCheck(http.HandlerFunc(handlersAdmin.LogoutPOSTHandler))).Methods("POST") // SAML ACS if adminConfig.Auth == settings.AuthSAML { routerAdmin.PathPrefix("/saml/").Handler(samlMiddleware) @@ -873,9 +876,6 @@ func osctrlAdminService() { routerAdmin.HandleFunc(logoutPath, func(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, samlConfig.LogoutURL, http.StatusFound) }).Methods("GET") - routerAdmin.HandleFunc(logoutPath, func(w http.ResponseWriter, r *http.Request) { - http.Redirect(w, r, samlConfig.LogoutURL, http.StatusFound) - }).Methods("POST") } // Launch HTTP server for admin serviceAdmin := adminConfig.Listener + ":" + adminConfig.Port diff --git a/admin/static/js/login.js b/admin/static/js/login.js index 819452d9..b51653db 100644 --- a/admin/static/js/login.js +++ b/admin/static/js/login.js @@ -19,7 +19,7 @@ function sendLogout() { var data = { csrftoken: _csrf }; - sendPostRequest(data, _url, '/login', false); + sendPostRequest(data, _url, '/logout', false); } $("#login_password").keyup(function(event) {