git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #197 from ruta-goomba/enterprise-github

use Github provider with GitHub enterprise

commit36128e971f2a01a289c2c5589ea388baa66821d0 authorJehiah Czebotar <jehiah@gmail.com> dateSat 6 Feb 2016, 13:24 (11 years ago) parent10f47e379b548d
2 files changed+9−3
README.md+6 providers/github.go+3−3
README.md+6
@@ -97,6 +97,12 @@ The GitHub auth provider supports two additional parameters to restrict authenti
9797 -github-org="": restrict logins to members of this organisation
9898 -github-team="": restrict logins to members of this team
9999
100+If you are using github enterprise, make sure you set the following to the appropriate url:
101+
102+ -login-url="<enterprise github url>/login/oauth/authorize"
103+ -redeem-url="<enterprise github url>/login/oauth/access_token"
104+ -validate-url="<enterprise github api url>/user/emails"
105+
100106
101107### LinkedIn Auth Provider
102108
providers/github.go+3−3
@@ -63,7 +63,7 @@ func (p *GitHubProvider) hasOrg(accessToken string) (bool, error) {
6363 "limit": {"100"},
6464 }
6565
66− endpoint := "https://api.github.com/user/orgs?" + params.Encode()
66+ endpoint := p.ValidateURL.Scheme + "://" + p.ValidateURL.Host + "/user/orgs?" + params.Encode()
6767 req, _ := http.NewRequest("GET", endpoint, nil)
6868 req.Header.Set("Accept", "application/vnd.github.v3+json")
6969 resp, err := http.DefaultClient.Do(req)
@@ -113,7 +113,7 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
113113 "limit": {"100"},
114114 }
115115
116− endpoint := "https://api.github.com/user/teams?" + params.Encode()
116+ endpoint := p.ValidateURL.Scheme + "://" + p.ValidateURL.Host + "/user/teams?" + params.Encode()
117117 req, _ := http.NewRequest("GET", endpoint, nil)
118118 req.Header.Set("Accept", "application/vnd.github.v3+json")
119119 resp, err := http.DefaultClient.Do(req)
@@ -183,7 +183,7 @@ func (p *GitHubProvider) GetEmailAddress(s *SessionState) (string, error) {
183183 params := url.Values{
184184 "access_token": {s.AccessToken},
185185 }
186− endpoint := "https://api.github.com/user/emails?" + params.Encode()
186+ endpoint := p.ValidateURL.Scheme + "://" + p.ValidateURL.Host + p.ValidateURL.Path + "?" + params.Encode()
187187 resp, err := http.DefaultClient.Get(endpoint)
188188 if err != nil {
189189 return "", err