git.iko.soy/typeable/oauth2-proxy
on master help sign in
Stop shadowing GetEmailAddress errors in redeemCode
commite0d915cc0347c8d026baa6bad205d7cc5564d932 authorNick Meves <nick.meves@greenhouse.io> dateWed 23 Sep 2020, 16:04 (6 years ago) parent3371284
2 files changed+11−6
CHANGELOG.md+1 oauthproxy.go+10−6
CHANGELOG.md+1
@@ -17,6 +17,7 @@
1717
1818- [#575](https://github.com/oauth2-proxy/oauth2-proxy/pull/575) Stop accepting legacy SHA1 signed cookies (@NickMeves)
1919- [#722](https://github.com/oauth2-proxy/oauth2-proxy/pull/722) Validate Redis configuration options at startup (@NickMeves)
20+- [#791](https://github.com/oauth2-proxy/oauth2-proxy/pull/791) Remove GetPreferredUsername method from provider interface (@NickMeves)
2021- [#764](https://github.com/oauth2-proxy/oauth2-proxy/pull/764) Document bcrypt encryption for htpasswd (and hide SHA) (@lentzi90)
2122- [#616](https://github.com/oauth2-proxy/oauth2-proxy/pull/616) Add support to ensure user belongs in required groups when using the OIDC provider (@stefansedich)
2223
oauthproxy.go+10−6
@@ -296,27 +296,31 @@ func (p *OAuthProxy) GetRedirectURI(host string) string {
296296 return u.String()
297297}
298298
299−func (p *OAuthProxy) redeemCode(ctx context.Context, host, code string) (s *sessionsapi.SessionState, err error) {
299+func (p *OAuthProxy) redeemCode(ctx context.Context, host, code string) (*sessionsapi.SessionState, error) {
300300 if code == "" {
301301 return nil, errors.New("missing code")
302302 }
303303 redirectURI := p.GetRedirectURI(host)
304− s, err = p.provider.Redeem(ctx, redirectURI, code)
304+ s, err := p.provider.Redeem(ctx, redirectURI, code)
305305 if err != nil {
306− return
306+ return nil, err
307307 }
308308
309309 if s.Email == "" {
310310 s.Email, err = p.provider.GetEmailAddress(ctx, s)
311+ if err != nil && err.Error() != "not implemented" {
312+ return nil, err
313+ }
311314 }
312315
313316 if s.User == "" {
314317 s.User, err = p.provider.GetUserName(ctx, s)
315− if err != nil && err.Error() == "not implemented" {
316− err = nil
318+ if err != nil && err.Error() != "not implemented" {
319+ return nil, err
317320 }
318321 }
319− return
322+
323+ return s, nil
320324}
321325
322326// MakeCSRFCookie creates a cookie for CSRF