Skip to content
Snippets Groups Projects
Commit 9e4b95f8 authored by ale's avatar ale
Browse files

Fix some lint warnings using 'nolint' instead of weird idioms

parent 57f0955d
No related branches found
No related tags found
No related merge requests found
...@@ -161,7 +161,7 @@ func (h *Server) loginCallback(w http.ResponseWriter, req *http.Request, usernam ...@@ -161,7 +161,7 @@ func (h *Server) loginCallback(w http.ResponseWriter, req *http.Request, usernam
// Create cookie-based session for the authenticated user. // Create cookie-based session for the authenticated user.
session := newAuthSession(h.authSessionLifetime, username, userinfo) session := newAuthSession(h.authSessionLifetime, username, userinfo)
httpSession, _ := h.authSessionStore.Get(req, authSessionKey) httpSession, _ := h.authSessionStore.Get(req, authSessionKey) // nolint
httpSession.Values["auth"] = session httpSession.Values["auth"] = session
return httpSession.Save(req, w) return httpSession.Save(req, w)
} }
...@@ -179,7 +179,9 @@ func (h *Server) withAuth(f func(http.ResponseWriter, *http.Request, *authSessio ...@@ -179,7 +179,9 @@ func (h *Server) withAuth(f func(http.ResponseWriter, *http.Request, *authSessio
return return
} }
httpSession.Options.MaxAge = -1 httpSession.Options.MaxAge = -1
_ = httpSession.Save(req, w) if err := httpSession.Save(req, w); err != nil {
log.Printf("error saving session: %v", err)
}
http.Redirect(w, req, makeLoginURL(req), http.StatusFound) http.Redirect(w, req, makeLoginURL(req), http.StatusFound)
}) })
} }
...@@ -227,7 +229,9 @@ func (h *Server) handleHomepage(w http.ResponseWriter, req *http.Request, sessio ...@@ -227,7 +229,9 @@ func (h *Server) handleHomepage(w http.ResponseWriter, req *http.Request, sessio
} }
session.AddService(service) session.AddService(service)
_ = sessions.Save(req, w) if err := sessions.Save(req, w); err != nil {
log.Printf("error saving session: %v", err)
}
// Redirect to service callback. // Redirect to service callback.
callbackURL := serviceLoginCallback(service, destination, token) callbackURL := serviceLoginCallback(service, destination, token)
...@@ -256,13 +260,13 @@ func (h *Server) handleLogout(w http.ResponseWriter, req *http.Request, session ...@@ -256,13 +260,13 @@ func (h *Server) handleLogout(w http.ResponseWriter, req *http.Request, session
if req.Method == "POST" { if req.Method == "POST" {
data["IsPOST"] = true data["IsPOST"] = true
data["IncludeLogoutScripts"] = true data["IncludeLogoutScripts"] = true
svcJSON, _ := json.Marshal(svcs) svcJSON, _ := json.Marshal(svcs) // nolint
data["ServicesJSON"] = string(svcJSON) data["ServicesJSON"] = string(svcJSON)
// Clear the local session. // Clear the local session. Ignore errors.
httpSession, _ := h.authSessionStore.Get(req, authSessionKey) httpSession, _ := h.authSessionStore.Get(req, authSessionKey) // nolint
httpSession.Options.MaxAge = -1 httpSession.Options.MaxAge = -1
_ = httpSession.Save(req, w) httpSession.Save(req, w) // nolint
// Close the keystore. // Close the keystore.
if h.keystore != nil { if h.keystore != nil {
...@@ -278,7 +282,7 @@ func (h *Server) handleLogout(w http.ResponseWriter, req *http.Request, session ...@@ -278,7 +282,7 @@ func (h *Server) handleLogout(w http.ResponseWriter, req *http.Request, session
w.Header().Set("Content-Security-Policy", logoutContentSecurityPolicy) w.Header().Set("Content-Security-Policy", logoutContentSecurityPolicy)
} }
h.tpl.ExecuteTemplate(w, "logout.html", data) h.tpl.ExecuteTemplate(w, "logout.html", data) // nolint
} }
func (h *Server) handleExchange(w http.ResponseWriter, req *http.Request) { func (h *Server) handleExchange(w http.ResponseWriter, req *http.Request) {
...@@ -301,7 +305,7 @@ func (h *Server) handleExchange(w http.ResponseWriter, req *http.Request) { ...@@ -301,7 +305,7 @@ func (h *Server) handleExchange(w http.ResponseWriter, req *http.Request) {
} }
w.Header().Set("Content-Type", "text/plain") w.Header().Set("Content-Type", "text/plain")
_, _ = io.WriteString(w, token) io.WriteString(w, token) // nolint
} }
// Handler returns the http.Handler for the SSO server application. // Handler returns the http.Handler for the SSO server application.
......
...@@ -131,7 +131,11 @@ func (l *loginHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { ...@@ -131,7 +131,11 @@ func (l *loginHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
case loginStateSuccess: case loginStateSuccess:
// Successful login. Delete the login session. // Successful login. Delete the login session.
httpSession.Options.MaxAge = -1 httpSession.Options.MaxAge = -1
_ = httpSession.Save(req, w) if err := httpSession.Save(req, w); err != nil {
log.Printf("login error saving session: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if err := l.loginCallback(w, req, session.Username, session.Password, session.UserInfo); err != nil { if err := l.loginCallback(w, req, session.Username, session.Password, session.UserInfo); err != nil {
log.Printf("login callback error: %v: user=%s", err, session.Username) log.Printf("login callback error: %v: user=%s", err, session.Username)
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
...@@ -146,7 +150,7 @@ func (l *loginHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { ...@@ -146,7 +150,7 @@ func (l *loginHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)
return return
} }
_, _ = w.Write(body) w.Write(body) // nolint
return return
default: default:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment