From 16ea1f18092026492740663fbdac1ae728339c16 Mon Sep 17 00:00:00 2001 From: Tharsanan1 Date: Fri, 25 Oct 2024 11:29:46 +0530 Subject: [PATCH] Fix padded jwt throwing invalid char error --- common-controller/internal/web/notify_handler.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common-controller/internal/web/notify_handler.go b/common-controller/internal/web/notify_handler.go index 6514f09db..1129e8404 100644 --- a/common-controller/internal/web/notify_handler.go +++ b/common-controller/internal/web/notify_handler.go @@ -228,7 +228,8 @@ func extractClaimsFromJWT(jwtToken string) (jWTClaims, error) { loggers.LoggerAPI.ErrorC(logging.PrintError(logging.Error3205, logging.MAJOR, "Invalid JWT")) return claims, fmt.Errorf("Invalid JWT token") } - payload, err := base64.RawURLEncoding.DecodeString(parts[1]) + payloadStr := strings.TrimRight(parts[1], "=") + payload, err := base64.RawURLEncoding.DecodeString(payloadStr) if err != nil { loggers.LoggerAPI.ErrorC(logging.PrintError(logging.Error3205, logging.MAJOR, "Invalid JWT")) return claims, fmt.Errorf("Error decoding payload: %v", err)