git.iko.soy/typeable/oauth2-proxy
on master help sign in
use base64.RawURLEncoding.DecodeString() in place of a bespoke function
commit8d6e16bf224cc429c95b6860bb438de7ed001053 authorColin Arnott <colin@urandom.co.uk> dateThu 13 Jul 2017, 18:29 (9 years ago) parent3c51c91
1 file changed+1−9
providers/google.go+1−9
providers/google.go+1−9
@@ -67,7 +67,7 @@ func emailFromIdToken(idToken string) (string, error) {
6767 // id_token is a base64 encode ID token payload
6868 // https://developers.google.com/accounts/docs/OAuth2Login#obtainuserinfo
6969 jwt := strings.Split(idToken, ".")
70− b, err := jwtDecodeSegment(jwt[1])
70+ b, err := base64.RawURLEncoding.DecodeString(jwt[1])
7171 if err != nil {
7272 return "", err
7373 }
@@ -89,14 +89,6 @@ func emailFromIdToken(idToken string) (string, error) {
8989 return email.Email, nil
9090}
9191
92−func jwtDecodeSegment(seg string) ([]byte, error) {
93− if l := len(seg) % 4; l > 0 {
94− seg += strings.Repeat("=", 4-l)
95− }
96−
97− return base64.URLEncoding.DecodeString(seg)
98−}
99−
10092func (p *GoogleProvider) Redeem(redirectURL, code string) (s *SessionState, err error) {
10193 if code == "" {
10294 err = errors.New("missing code")