From 542ef540939cbea0e58f4744a0216b68c9579ff6 Mon Sep 17 00:00:00 2001 From: Daniel Lamando Date: Thu, 8 Mar 2018 16:44:11 -0800 Subject: [PATCH] Strip JWT base64 padding before parsing. #560 --- providers/google.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/providers/google.go b/providers/google.go index 4bf108e..66406bd 100644 --- a/providers/google.go +++ b/providers/google.go @@ -67,7 +67,8 @@ func emailFromIdToken(idToken string) (string, error) { // id_token is a base64 encode ID token payload // https://developers.google.com/accounts/docs/OAuth2Login#obtainuserinfo jwt := strings.Split(idToken, ".") - b, err := base64.RawURLEncoding.DecodeString(jwt[1]) + jwtData := strings.TrimSuffix(jwt[1], "=") + b, err := base64.RawURLEncoding.DecodeString(jwtData) if err != nil { return "", err }