Strip JWT base64 padding before parsing. #560

This commit is contained in:
Daniel Lamando 2018-03-08 16:44:11 -08:00 committed by GitHub
parent ae49c7d23c
commit 542ef54093
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
} }