From 7d5f42e61adf58d9dca5acbc7f1e062c3096557b Mon Sep 17 00:00:00 2001 From: LightJack05 <66321084+LightJack05@users.noreply.github.com> Date: Wed, 21 Jan 2026 17:01:41 +0100 Subject: [PATCH 1/2] Added better log messages to auth lib --- middleware.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/middleware.go b/middleware.go index c2ce01b..a45a72b 100644 --- a/middleware.go +++ b/middleware.go @@ -30,6 +30,7 @@ func Authentication(c *gin.Context) { requestUrl := fmt.Sprintf("%s/%s", serviceconfig.GetConfig().ApiRootUrl, "auth/session") request, err := http.NewRequest("GET", requestUrl, nil) if err != nil { + log.Printf("Failed to contacft auth service at %s: %v", requestUrl, err) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "Failed to create request"}) return } @@ -38,6 +39,7 @@ func Authentication(c *gin.Context) { client := &http.Client{} response, err := client.Do(request) if err != nil || response.StatusCode != http.StatusOK { + log.Printf("Failed to validate session with auth service at %s: %v", requestUrl, err) c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"}) return } @@ -45,12 +47,14 @@ func Authentication(c *gin.Context) { defer response.Body.Close() body, err := io.ReadAll(response.Body) if err != nil { + log.Printf("Failed to read response from auth service at %s: %v", requestUrl, err) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "Failed to read response body"}) return } var authResp authServiceResponse if err := json.Unmarshal(body, &authResp); err != nil { + log.Printf("Failed to parse response from auth service at %s: %v", requestUrl, err) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "Failed to parse response"}) return } From 27cb3420714b9883c3a950526104937010a0e868 Mon Sep 17 00:00:00 2001 From: LightJack05 <66321084+LightJack05@users.noreply.github.com> Date: Wed, 21 Jan 2026 17:02:47 +0100 Subject: [PATCH 2/2] Update log mesages with prefix --- middleware.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/middleware.go b/middleware.go index a45a72b..fe51f88 100644 --- a/middleware.go +++ b/middleware.go @@ -30,7 +30,7 @@ func Authentication(c *gin.Context) { requestUrl := fmt.Sprintf("%s/%s", serviceconfig.GetConfig().ApiRootUrl, "auth/session") request, err := http.NewRequest("GET", requestUrl, nil) if err != nil { - log.Printf("Failed to contacft auth service at %s: %v", requestUrl, err) + log.Printf("[AUTH] Failed to contacft auth service at %s: %v", requestUrl, err) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "Failed to create request"}) return } @@ -39,7 +39,7 @@ func Authentication(c *gin.Context) { client := &http.Client{} response, err := client.Do(request) if err != nil || response.StatusCode != http.StatusOK { - log.Printf("Failed to validate session with auth service at %s: %v", requestUrl, err) + log.Printf("[AUTH] Failed to validate session with auth service at %s: %v", requestUrl, err) c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"}) return } @@ -47,14 +47,14 @@ func Authentication(c *gin.Context) { defer response.Body.Close() body, err := io.ReadAll(response.Body) if err != nil { - log.Printf("Failed to read response from auth service at %s: %v", requestUrl, err) + log.Printf("[AUTH] Failed to read response from auth service at %s: %v", requestUrl, err) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "Failed to read response body"}) return } var authResp authServiceResponse if err := json.Unmarshal(body, &authResp); err != nil { - log.Printf("Failed to parse response from auth service at %s: %v", requestUrl, err) + log.Printf("[AUTH] Failed to parse response from auth service at %s: %v", requestUrl, err) c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": "Failed to parse response"}) return }