Skip to content

Commit

Permalink
Ignore spaces in authorized emails list
Browse files Browse the repository at this point in the history
adding enterprise github provider

print the error stack trace

point to my fork in oauthproxy.go

addint pointers to ruta-goomba fork in mulitple files

change api endpoint

replace hard-coded github api endpoint with variables

resetting fall through github urls to point to github.com

fix malformed url

remove pointers to fork files

removing comment changes and cookie error output changes

replace spacing changes
  • Loading branch information
Stan Hu authored and Ruta Sakalauskaite committed Jan 21, 2016
1 parent beebf4d commit 059dcbf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 3 additions & 3 deletions providers/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (p *GitHubProvider) hasOrg(accessToken string) (bool, error) {
"limit": {"100"},
}

endpoint := "https://api.github.com/user/orgs?" + params.Encode()
endpoint := p.ValidateURL.Scheme + "://" + p.ValidateURL.Host + "/user/orgs?" + params.Encode()
req, _ := http.NewRequest("GET", endpoint, nil)
req.Header.Set("Accept", "application/vnd.github.v3+json")
resp, err := http.DefaultClient.Do(req)
Expand Down Expand Up @@ -113,7 +113,7 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
"limit": {"100"},
}

endpoint := "https://api.github.com/user/teams?" + params.Encode()
endpoint := p.ValidateURL.Scheme + "://" + p.ValidateURL.Host + "/user/teams?" + params.Encode()
req, _ := http.NewRequest("GET", endpoint, nil)
req.Header.Set("Accept", "application/vnd.github.v3+json")
resp, err := http.DefaultClient.Do(req)
Expand Down Expand Up @@ -183,7 +183,7 @@ func (p *GitHubProvider) GetEmailAddress(s *SessionState) (string, error) {
params := url.Values{
"access_token": {s.AccessToken},
}
endpoint := "https://api.github.com/user/emails?" + params.Encode()
endpoint := p.ValidateURL.Scheme + "://" + p.ValidateURL.Host + p.ValidateURL.Path + "?" + params.Encode()
resp, err := http.DefaultClient.Get(endpoint)
if err != nil {
return "", err
Expand Down
3 changes: 2 additions & 1 deletion validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func (um *UserMap) LoadAuthenticatedEmailsFile() {
}
updated := make(map[string]bool)
for _, r := range records {
updated[strings.ToLower(r[0])] = true
address := strings.ToLower(strings.TrimSpace(r[0]))
updated[address] = true
}
atomic.StorePointer(&um.m, unsafe.Pointer(&updated))
}
Expand Down
13 changes: 13 additions & 0 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,16 @@ func TestValidatorComparisonsAreCaseInsensitive(t *testing.T) {
t.Error("validated domains are not lower-cased")
}
}

func TestValidatorIgnoreSpacesInAuthEmails(t *testing.T) {
vt := NewValidatorTest(t)
defer vt.TearDown()

vt.WriteEmails(t, []string{" foo.bar@example.com "})
domains := []string(nil)
validator := vt.NewValidator(domains, nil)

if !validator("foo.bar@example.com") {
t.Error("email should validate")
}
}

0 comments on commit 059dcbf

Please sign in to comment.