aboutsummaryrefslogtreecommitdiff
path: root/server/auth/github/github.go
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2016-06-15 09:42:44 +0100
committerGitHub <noreply@github.com>2016-06-15 09:42:44 +0100
commitbbbe873ebd93821f0db0a9d88dbbeccf3679f290 (patch)
treecc55353786fcbe1424abd18382f32ab63e3473a2 /server/auth/github/github.go
parent77c2a94644dd7ec9c3ae8c995c32f2ad8d90a7b1 (diff)
parentcd138ddf742d124aea3d1e7f155735576459be67 (diff)
Merge pull request #22 from nsheridan/whitelist
Update whitelisting
Diffstat (limited to 'server/auth/github/github.go')
-rw-r--r--server/auth/github/github.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/server/auth/github/github.go b/server/auth/github/github.go
index 912caae..24a4bbf 100644
--- a/server/auth/github/github.go
+++ b/server/auth/github/github.go
@@ -62,12 +62,17 @@ func (c *Config) Name() string {
// Valid validates the oauth token.
func (c *Config) Valid(token *oauth2.Token) bool {
- if len(c.whitelist) == 0 && !c.whitelist[c.Username(token)] {
+ if len(c.whitelist) > 0 && !c.whitelist[c.Username(token)] {
return false
}
if !token.Valid() {
return false
}
+ if c.organization == "" {
+ // There's no organization and the token is valid. Can only reach here
+ // if there's a user whitelist set and the user is in the whitelist.
+ return true
+ }
client := githubapi.NewClient(c.newClient(token))
member, _, err := client.Organizations.IsMember(c.organization, c.Username(token))
if err != nil {