From f5776562cc2973fab032683c249c534d8054f779 Mon Sep 17 00:00:00 2001 From: khaliq Date: Sat, 16 Mar 2024 13:12:25 +0500 Subject: [PATCH] fix: add user info to the logs --- internal/auth/auth.go | 2 +- main.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/auth/auth.go b/internal/auth/auth.go index fcf37a7..db86b67 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -89,7 +89,7 @@ func (provider *OIDCProviderInfo) VerifyToken(aToken string) error { ctx := context.Background() _, err := provider.KeySet.VerifySignature(ctx, aToken) if err != nil { - return fmt.Errorf("Access token verification failed:", err) + return fmt.Errorf("Access token verification failed: %v", err) } // Set up the JWT token parser diff --git a/main.go b/main.go index 30cb261..a846991 100644 --- a/main.go +++ b/main.go @@ -34,21 +34,21 @@ func main() { // Get provider configuration provider, err := auth.GetProviderInfo(providerEndpoint) if err != nil { - log.Fatalf("Failed to retrieve provider configuration: %v\n", err) + log.Fatalf("Failed to retrieve provider configuration for provider %v with error %v\n", providerEndpoint, err) } // Retrieve an OIDC token using the password grant type accessToken, err := auth.RequestJWT(username, password, otp, provider.TokenURL, c.ClientID, c.ClientSecret, c.ClientScope) if err != nil { - log.Fatalf("Failed to retrieve token: %v\n", err) + log.Fatalf("Failed to retrieve token for %v - error: %v\n", username, err) os.Exit(2) } // Verify the token and retrieve the ID token if err := provider.VerifyToken(accessToken); err != nil { // handle the error - log.Fatal(err) + log.Fatalf("Failed to verify token %v for user %v\n", err, username) os.Exit(3) } - log.Println("Token acquired and verified Successfully.") + log.Println("Token acquired and verified Successfully for user -", username) }