From 8d6e16bf224cc429c95b6860bb438de7ed001053 Mon Sep 17 00:00:00 2001 From: Colin Arnott Date: Thu, 13 Jul 2017 18:29:58 +0000 Subject: [PATCH] use base64.RawURLEncoding.DecodeString() in place of a bespoke function --- providers/google.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/providers/google.go b/providers/google.go index a9cb487..4bf108e 100644 --- a/providers/google.go +++ b/providers/google.go @@ -67,7 +67,7 @@ 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 := jwtDecodeSegment(jwt[1]) + b, err := base64.RawURLEncoding.DecodeString(jwt[1]) if err != nil { return "", err } @@ -89,14 +89,6 @@ func emailFromIdToken(idToken string) (string, error) { return email.Email, nil } -func jwtDecodeSegment(seg string) ([]byte, error) { - if l := len(seg) % 4; l > 0 { - seg += strings.Repeat("=", 4-l) - } - - return base64.URLEncoding.DecodeString(seg) -} - func (p *GoogleProvider) Redeem(redirectURL, code string) (s *SessionState, err error) { if code == "" { err = errors.New("missing code")