Merge pull request #421 from arnottcr/raw-url-encode

raw url encoding
This commit is contained in:
Tanvir Alam 2017-11-20 10:50:56 -05:00 committed by GitHub
commit a7c5d9c478
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,7 +67,7 @@ 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 := jwtDecodeSegment(jwt[1]) b, err := base64.RawURLEncoding.DecodeString(jwt[1])
if err != nil { if err != nil {
return "", err return "", err
} }
@ -89,14 +89,6 @@ func emailFromIdToken(idToken string) (string, error) {
return email.Email, nil 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) { func (p *GoogleProvider) Redeem(redirectURL, code string) (s *SessionState, err error) {
if code == "" { if code == "" {
err = errors.New("missing code") err = errors.New("missing code")