git.iko.soy/typeable/oauth2-proxy
on master help sign in
fix: should check if email is verified
commitb49aeb222b820b13a8e9f5430c1201a24cf52b13 authorCarlos Alexandro Becker <caarlos0@gmail.com> dateMon 11 Mar 2019, 14:52 (8 years ago) parent056089b
2 files changed+6−6
providers/github.go+3−3 providers/github_test.go+3−3
providers/github.go+3−3
@@ -202,8 +202,8 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
202202func (p *GitHubProvider) GetEmailAddress(s *SessionState) (string, error) {
203203
204204 var emails []struct {
205− Email string `json:"email"`
206− Primary bool `json:"primary"`
205+ Email string `json:"email"`
206+ Verified bool `json:"verified"`
207207 }
208208
209209 // if we require an Org or Team, check that first
@@ -248,7 +248,7 @@ func (p *GitHubProvider) GetEmailAddress(s *SessionState) (string, error) {
248248 }
249249
250250 for _, email := range emails {
251− if email.Primary {
251+ if email.Verified {
252252 return email.Email, nil
253253 }
254254 }
providers/github_test.go+3−3
@@ -97,7 +97,7 @@ func TestGitHubProviderOverrides(t *testing.T) {
9797}
9898
9999func TestGitHubProviderGetEmailAddress(t *testing.T) {
100− b := testGitHubBackend([]string{`[ {"email": "michael.bland@gsa.gov", "primary": true} ]`})
100+ b := testGitHubBackend([]string{`[ {"email": "michael.bland@gsa.gov", "verified": true} ]`})
101101 defer b.Close()
102102
103103 bURL, _ := url.Parse(b.URL)
@@ -111,8 +111,8 @@ func TestGitHubProviderGetEmailAddress(t *testing.T) {
111111
112112func TestGitHubProviderGetEmailAddressWithOrg(t *testing.T) {
113113 b := testGitHubBackend([]string{
114− `[ {"email": "michael.bland@gsa.gov", "primary": true, "login":"testorg"} ]`,
115− `[ {"email": "michael.bland1@gsa.gov", "primary": true, "login":"testorg1"} ]`,
114+ `[ {"email": "michael.bland@gsa.gov", "verified": true, "login":"testorg"} ]`,
115+ `[ {"email": "michael.bland1@gsa.gov", "verified": true, "login":"testorg1"} ]`,
116116 `[ ]`,
117117 })
118118 defer b.Close()