From a9cf8b3313674f60b6eb8d0b119f88fc5732c19a Mon Sep 17 00:00:00 2001 From: Ruta Sakalauskaite Date: Mon, 18 Jan 2016 17:33:25 +0000 Subject: [PATCH 1/2] 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 changes to enable use with enterprise github --- providers/github.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/providers/github.go b/providers/github.go index cf0cfcb..124eebe 100644 --- a/providers/github.go +++ b/providers/github.go @@ -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) @@ -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) @@ -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 From 79b548dae696dbad05d5689451acaf9749e3d119 Mon Sep 17 00:00:00 2001 From: Ruta Sakalauskaite Date: Thu, 21 Jan 2016 21:54:29 +0000 Subject: [PATCH 2/2] modifying README to add information about use with enterprise github --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index da71e1b..611a049 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,12 @@ The GitHub auth provider supports two additional parameters to restrict authenti -github-org="": restrict logins to members of this organisation -github-team="": restrict logins to members of this team +If you are using github enterprise, make sure you set the following to the appropriate url: + + -login-url="/login/oauth/authorize" + -redeem-url="/login/oauth/access_token" + -validate-url="/user/emails" + ### LinkedIn Auth Provider