Skip to content

Commit

Permalink
Merge pull request #317 from oscarlofwenhamn/patch-1
Browse files Browse the repository at this point in the history
Make decodeJWT use URLEncoding without padding
  • Loading branch information
bentranter authored Feb 24, 2020
2 parents 8a9b881 + 8242566 commit 06e1f81
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions providers/openidConnect/openidConnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,8 @@ func decodeJWT(jwt string) (map[string]interface{}, error) {
return nil, errors.New("jws: invalid token received, not all parts available")
}

// Re-pad, if needed
encodedPayload := jwtParts[1]
if l := len(encodedPayload) % 4; l != 0 {
encodedPayload += strings.Repeat("=", 4-l)
}
decodedPayload, err := base64.URLEncoding.WithPadding(base64.NoPadding).DecodeString(jwtParts[1])

decodedPayload, err := base64.StdEncoding.DecodeString(encodedPayload)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 06e1f81

Please sign in to comment.