From 35a76d1a33bcbaf5bf9b0dd5ce6b72ae7c4e23fe Mon Sep 17 00:00:00 2001 From: Flint Gatrell <996640+flintg@users.noreply.github.com> Date: Fri, 9 May 2025 12:24:58 -0600 Subject: [PATCH 1/3] Fprintf() expects formatting, but none was applied. Changed to Fprint() instead. --- complete-application/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/complete-application/main.go b/complete-application/main.go index 8215497..2a1574f 100644 --- a/complete-application/main.go +++ b/complete-application/main.go @@ -182,7 +182,7 @@ func isAuthorized(endpoint func(http.ResponseWriter, *http.Request)) http.Handle return verifyKey, nil }) if err != nil { - fmt.Fprintf(w, err.Error()) + fmt.Fprint(w, err.Error()) return } From e1f88d1c850aafd32d0c77fc0b45b29f1f1d6f70 Mon Sep 17 00:00:00 2001 From: Flint Gatrell <996640+flintg@users.noreply.github.com> Date: Fri, 9 May 2025 12:27:47 -0600 Subject: [PATCH 2/3] Nothing happens in the else block here, so it can be removed and be consistent with the rest of the code in main. --- complete-application/main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/complete-application/main.go b/complete-application/main.go index 2a1574f..e4eeb34 100644 --- a/complete-application/main.go +++ b/complete-application/main.go @@ -151,7 +151,6 @@ func isAuthorized(endpoint func(http.ResponseWriter, *http.Request)) http.Handle reqToken = r.Header.Get("Authorization") splitToken := strings.Split(reqToken, "Bearer ") reqToken = splitToken[1] - } else { } } else { reqToken = tokenCookie.Value From 13c6a0cf8b61865d9511983a3debc7b8ff3f8fa2 Mon Sep 17 00:00:00 2001 From: Flint Gatrell <996640+flintg@users.noreply.github.com> Date: Fri, 9 May 2025 12:44:40 -0600 Subject: [PATCH 3/3] The first result returned by r.Header.Get("Authorization") is never used and is immediately overwritten by the second call to the function. Even if two Authorization headers were present, this function only returns the value of the first it encounters. Removing the superfluous call. --- complete-application/main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/complete-application/main.go b/complete-application/main.go index e4eeb34..4b4221c 100644 --- a/complete-application/main.go +++ b/complete-application/main.go @@ -147,7 +147,6 @@ func isAuthorized(endpoint func(http.ResponseWriter, *http.Request)) http.Handle tokenCookie, err := r.Cookie("app.at") if err != nil { if errors.Is(err, http.ErrNoCookie) { - reqToken = r.Header.Get("Authorization") reqToken = r.Header.Get("Authorization") splitToken := strings.Split(reqToken, "Bearer ") reqToken = splitToken[1]