Merge pull request #561 from danopia/patch-1

Strip JWT base64 padding before parsing. #560
This commit is contained in:
Jehiah Czebotar 2018-03-24 23:45:15 -04:00 committed by GitHub
commit 1c1db881c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,7 +67,8 @@ func emailFromIdToken(idToken string) (string, error) {
// id_token is a base64 encode ID token payload // id_token is a base64 encode ID token payload
// https://developers.google.com/accounts/docs/OAuth2Login#obtainuserinfo // https://developers.google.com/accounts/docs/OAuth2Login#obtainuserinfo
jwt := strings.Split(idToken, ".") 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 { if err != nil {
return "", err return "", err
} }