git.iko.soy/typeable/oauth2-proxy
on master help sign in
Merge pull request #214 from raphink/github_multiple_teams

github provider: allow multiple teams

commit293d674e1417e22d5c669428eaed48c3383edf18 authorJehiah Czebotar <jehiah@gmail.com> dateWed 17 Feb 2016, 17:24 (11 years ago) parentbfb8dc1338e997
2 files changed+8−4
README.md+1−1 providers/github.go+7−3
README.md+1−1
@@ -95,7 +95,7 @@ The Azure AD auth provider uses `openid` as it default scope. It uses `https://g
9595The GitHub auth provider supports two additional parameters to restrict authentication to Organization or Team level access. Restricting by org and team is normally accompanied with `--email-domain=*`
9696
9797 -github-org="": restrict logins to members of this organisation
98− -github-team="": restrict logins to members of this team
98+ -github-team="": restrict logins to members of any of these teams, separated by a comma
9999
100100If you are using github enterprise, make sure you set the following to the appropriate url:
101101
providers/github.go+7−3
@@ -3,6 +3,7 @@ package providers
33import (
44 "encoding/json"
55 "fmt"
6+ "strings"
67 "io/ioutil"
78 "log"
89 "net/http"
@@ -141,9 +142,12 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
141142 presentOrgs[team.Org.Login] = true
142143 if p.Org == team.Org.Login {
143144 hasOrg = true
144− if p.Team == team.Slug {
145− log.Printf("Found Github Organization:%q Team:%q (Name:%q)", team.Org.Login, team.Slug, team.Name)
146− return true, nil
145+ ts := strings.Split(p.Team, ",")
146+ for _, t := range ts {
147+ if t == team.Slug {
148+ log.Printf("Found Github Organization:%q Team:%q (Name:%q)", team.Org.Login, team.Slug, team.Name)
149+ return true, nil
150+ }
147151 }
148152 presentTeams = append(presentTeams, team.Slug)
149153 }