Skip to content

Commit ca6193b

Browse files
authored
Merge pull request #57 from ploxiln/options_consistency
rename a few config options for consistency
2 parents 434122a + f68d247 commit ca6193b

File tree

4 files changed

+22
-23
lines changed

4 files changed

+22
-23
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ The Azure AD auth provider uses `openid` as it default scope. It uses `https://g
145145
The 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=*`
146146

147147
-github-org="": restrict logins to members of this organisation
148-
-github-team="": restrict logins to members of any of these teams (slug), separated by a comma
148+
-github-team="": restrict logins to members of this team (slug) (or teams, if this flag is given multiple times)
149149

150150
If you are using GitHub enterprise, make sure you set the following to the appropriate url:
151151

@@ -321,8 +321,8 @@ Usage of oauth2_proxy:
321321
-skip-oidc-discovery: Skip OIDC discovery (login-url, redeem-url and oidc-jwks-url must be configured)
322322
-skip-provider-button: will skip sign-in-page to directly reach the next step: oauth/start
323323
-ssl-insecure-skip-verify: skip validation of certificates presented when using HTTPS
324-
-tls-cert string: path to certificate file
325-
-tls-key string: path to private key file
324+
-tls-cert-file string: path to certificate file
325+
-tls-key-file string: path to private key file
326326
-upstream value: the http url(s) of the upstream endpoint or file:// paths for static files. Routing is based on the path
327327
-validate-url string: Access token validation endpoint
328328
-version: print version string

main.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ func mainFlagSet() *flag.FlagSet {
2323
skipAuthRegex := StringArray{}
2424
googleGroups := StringArray{}
2525
gitlabGroups := StringArray{}
26+
githubTeams := StringArray{}
2627

2728
flagSet.String("http-address", "127.0.0.1:4180", "[http://]<addr>:<port> or unix://<path> to listen on for HTTP clients")
2829
flagSet.String("https-address", ":443", "<addr>:<port> to listen on for HTTPS clients")
2930
flagSet.Bool("force-https", false, "redirect http requests to https")
30-
flagSet.String("tls-cert", "", "path to certificate file")
31-
flagSet.String("tls-key", "", "path to private key file")
31+
flagSet.String("tls-cert-file", "", "path to certificate file")
32+
flagSet.String("tls-key-file", "", "path to private key file")
3233
flagSet.String("redirect-url", "", "the OAuth Redirect URL. ie: \"https://internalapp.yourcompany.com/oauth2/callback\"")
3334
flagSet.Var(&upstreams, "upstream", "the http url(s) of the upstream endpoint or file:// paths for static files. Routing is based on the path")
3435
flagSet.Bool("set-xauthrequest", false, "set X-Auth-Request-User and X-Auth-Request-Email response headers (useful in Nginx auth_request mode)")
@@ -48,7 +49,7 @@ func mainFlagSet() *flag.FlagSet {
4849
flagSet.String("azure-tenant", "common", "go to a tenant-specific or common (tenant-independent) endpoint.")
4950
flagSet.String("bitbucket-team", "", "restrict logins to members of this team")
5051
flagSet.String("github-org", "", "restrict logins to members of this organisation")
51-
flagSet.String("github-team", "", "restrict logins to members of this team (slug) (may be given multiple times)")
52+
flagSet.Var(&githubTeams, "github-team", "restrict logins to members of this team (slug) (may be given multiple times)")
5253
flagSet.Var(&gitlabGroups, "gitlab-group", "restrict logins to members of this group (full path) (may be given multiple times)")
5354
flagSet.Var(&googleGroups, "google-group", "restrict logins to members of this google group (may be given multiple times)")
5455
flagSet.String("google-admin-email", "", "the google admin to impersonate for api calls")

options.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ import (
1818

1919
// Configuration Options that can be set by Command Line Flag, or Config File
2020
type Options struct {
21-
ProxyPrefix string `flag:"proxy-prefix" cfg:"proxy-prefix"`
21+
ProxyPrefix string `flag:"proxy-prefix" cfg:"proxy_prefix"`
2222
ProxyWebSockets bool `flag:"proxy-websockets" cfg:"proxy_websockets"`
2323
HttpAddress string `flag:"http-address" cfg:"http_address"`
2424
HttpsAddress string `flag:"https-address" cfg:"https_address"`
2525
ForceHTTPS bool `flag:"force-https" cfg:"force_https"`
2626
RedirectURL string `flag:"redirect-url" cfg:"redirect_url"`
2727
ClientID string `flag:"client-id" cfg:"client_id" env:"OAUTH2_PROXY_CLIENT_ID"`
2828
ClientSecret string `flag:"client-secret" cfg:"client_secret" env:"OAUTH2_PROXY_CLIENT_SECRET"`
29-
TLSCertFile string `flag:"tls-cert" cfg:"tls_cert_file"`
30-
TLSKeyFile string `flag:"tls-key" cfg:"tls_key_file"`
29+
TLSCertFile string `flag:"tls-cert-file" cfg:"tls_cert_file"`
30+
TLSKeyFile string `flag:"tls-key-file" cfg:"tls_key_file"`
3131

3232
AuthenticatedEmailsFile string `flag:"authenticated-emails-file" cfg:"authenticated_emails_file"`
3333
AzureTenant string `flag:"azure-tenant" cfg:"azure_tenant"`
3434
BitbucketTeam string `flag:"bitbucket-team" cfg:"bitbucket_team"`
3535
EmailDomains []string `flag:"email-domain" cfg:"email_domains"`
3636
WhitelistDomains []string `flag:"whitelist-domain" cfg:"whitelist_domains" env:"OAUTH2_PROXY_WHITELIST_DOMAINS"`
3737
GitHubOrg string `flag:"github-org" cfg:"github_org"`
38-
GitHubTeam string `flag:"github-team" cfg:"github_team"`
38+
GitHubTeams []string `flag:"github-team" cfg:"github_teams"`
3939
GitLabGroups []string `flag:"gitlab-group" cfg:"gitlab_groups"`
40-
GoogleGroups []string `flag:"google-group" cfg:"google_group"`
40+
GoogleGroups []string `flag:"google-group" cfg:"google_groups"`
4141
GoogleAdminEmail string `flag:"google-admin-email" cfg:"google_admin_email"`
4242
GoogleServiceAccountJSON string `flag:"google-service-account-json" cfg:"google_service_account_json"`
4343
HtpasswdFile string `flag:"htpasswd-file" cfg:"htpasswd_file"`
@@ -272,7 +272,7 @@ func parseProviderInfo(o *Options, msgs []string) []string {
272272
case *providers.BitbucketProvider:
273273
p.SetTeam(o.BitbucketTeam)
274274
case *providers.GitHubProvider:
275-
p.SetOrgTeam(o.GitHubOrg, o.GitHubTeam)
275+
p.SetOrgTeam(o.GitHubOrg, o.GitHubTeams)
276276
case *providers.GitLabProvider:
277277
p.SetGroups(o.GitLabGroups)
278278
case *providers.GoogleProvider:

providers/github.go

+9-11
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ import (
1010
"path"
1111
"regexp"
1212
"strconv"
13-
"strings"
1413
)
1514

1615
type GitHubProvider struct {
1716
*ProviderData
18-
Org string
19-
Team string
17+
Org string
18+
Teams []string
2019
}
2120

2221
func NewGitHubProvider(p *ProviderData) *GitHubProvider {
@@ -56,10 +55,10 @@ func getGitHubHeader(accessToken string) http.Header {
5655
return header
5756
}
5857

59-
func (p *GitHubProvider) SetOrgTeam(org, team string) {
58+
func (p *GitHubProvider) SetOrgTeam(org string, teams []string) {
6059
p.Org = org
61-
p.Team = team
62-
if org != "" || team != "" {
60+
p.Teams = teams
61+
if org != "" || len(teams) > 0 {
6362
p.Scope += " read:org"
6463
}
6564
}
@@ -178,8 +177,7 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
178177
presentOrgs[team.Org.Login] = true
179178
if p.Org == team.Org.Login {
180179
hasOrg = true
181-
ts := strings.Split(p.Team, ",")
182-
for _, t := range ts {
180+
for _, t := range p.Teams {
183181
if t == team.Slug {
184182
log.Printf("Found Github Organization:%q Team:%q (Name:%q)",
185183
team.Org.Login, team.Slug, team.Name)
@@ -198,13 +196,13 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
198196
}
199197

200198
if hasOrg {
201-
log.Printf("Missing Team:%q from Org:%q in teams: %v", p.Team, p.Org, presentTeams)
199+
log.Printf("Missing Team:%v from Org:%q in teams: %v", p.Teams, p.Org, presentTeams)
202200
} else {
203201
var allOrgs []string
204202
for org, _ := range presentOrgs {
205203
allOrgs = append(allOrgs, org)
206204
}
207-
log.Printf("Missing Organization:%q in %#v", p.Org, allOrgs)
205+
log.Printf("Missing Organization:%q in %v", p.Org, allOrgs)
208206
}
209207
return false, nil
210208
}
@@ -219,7 +217,7 @@ func (p *GitHubProvider) GetEmailAddress(s *SessionState) (string, error) {
219217

220218
// if we require an Org or Team, check that first
221219
if p.Org != "" {
222-
if p.Team != "" {
220+
if len(p.Teams) > 0 {
223221
if ok, err := p.hasOrgAndTeam(s.AccessToken); err != nil || !ok {
224222
return "", err
225223
}

0 commit comments

Comments
 (0)