git.iko.soy/typeable/oauth2-proxy
on master help sign in
GitHub Provider - Fallback to secondary verified email (#372)

* Fallback to secondary verified email * Add change to changelog

commit3a843f815d8bec6792eaee35bc812d06788c533f authorDevin Nemec <devin.nemec@gmail.com> dateSat 15 Feb 2020, 07:36 (7 years ago) parent10adb5c
2 files changed+8−3
CHANGELOG.md+1 providers/github.go+7−3
CHANGELOG.md+1
@@ -9,6 +9,7 @@
99
1010## Changes since v5.0.0
1111
12+- [#372](https://github.com/pusher/oauth2_proxy/pull/372) Allow fallback to secondary verified email address in GitHub provider (@dmnemec)
1213- [#335](https://github.com/pusher/oauth2_proxy/pull/335) OIDC Provider support for empty id_tokens in the access token refresh response (@howzat)
1314- [#363](https://github.com/pusher/oauth2_proxy/pull/363) Extension of Redis Session Store to Support Redis Cluster (@yan-dblinf)
1415- [#353](https://github.com/pusher/oauth2_proxy/pull/353) Fix login page fragment handling after soft reload on Firefox (@ffdybuster)
providers/github.go+7−3
@@ -305,13 +305,17 @@ func (p *GitHubProvider) GetEmailAddress(s *sessions.SessionState) (string, erro
305305 return "", fmt.Errorf("%s unmarshaling %s", err, body)
306306 }
307307
308+ returnEmail := ""
308309 for _, email := range emails {
309− if email.Primary && email.Verified {
310− return email.Email, nil
310+ if email.Verified {
311+ returnEmail = email.Email
312+ if email.Primary {
313+ return returnEmail, nil
314+ }
311315 }
312316 }
313317
314− return "", nil
318+ return returnEmail, nil
315319}
316320
317321// GetUserName returns the Account user name