From c5ec176a1cfba4f170991ca7bf6296185b10f565 Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Sun, 21 Oct 2018 15:34:30 +0100 Subject: Gitlab auth issue (#79) * Fix the gitlab oauth issue. * Update for gitlab 11.1+ Versions beyond 11.1 (and possibly a few releases before) use a different method for delivering tokens. They also have disabled version 3 of the api. These changes address that and add a debugging mode for the server that make it easier to debug issues like this in the future. * Cleanup of PR. Updated README. Removed code duplication. --- server/handlers.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'server/handlers.go') diff --git a/server/handlers.go b/server/handlers.go index 4d9543b..3f3543e 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -88,6 +88,7 @@ func (a *app) auth(w http.ResponseWriter, r *http.Request) { case "/auth/callback": state := a.getSessionVariable(r, "state") if r.FormValue("state") != state { + log.Printf("Not authorized on /auth/callback") w.WriteHeader(http.StatusUnauthorized) w.Write([]byte(http.StatusText(http.StatusUnauthorized))) break @@ -99,11 +100,13 @@ func (a *app) auth(w http.ResponseWriter, r *http.Request) { code := r.FormValue("code") token, err := a.authprovider.Exchange(code) if err != nil { + log.Printf("Error on /auth/callback: %v", err) w.WriteHeader(http.StatusInternalServerError) w.Write([]byte(http.StatusText(http.StatusInternalServerError))) w.Write([]byte(err.Error())) break } + log.Printf("Token found on /auth/callback, redirecting to %s", originURL) a.setAuthToken(w, r, token) http.Redirect(w, r, originURL, http.StatusFound) default: -- cgit v1.2.3