-
Notifications
You must be signed in to change notification settings - Fork 15
Allow limiting authentication to members of a specific GitHub org #14
Conversation
@@ -81,6 +82,13 @@ AuthenticateGithub.prototype.getAuthorizationToken = function(username, password | |||
if (err) reject(err); | |||
else resolve(res.token); | |||
}); | |||
}).then(this.githubOrg && function(token) { | |||
return new Promise(function(resolve, reject) { | |||
github.orgs.getMember({ user: username, org: _this.githubOrg }, function(err, res) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on this logic, I gather an error is returned if a user is not a member of the organization? You've confirmed this behavior hitting the live API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have confirmed this behaviour on the live API, yes.
These two authenticating as me, a member of npm:
~ ⮀ curl -siLn https://api.github.com/orgs/npm/members/nathan7 | grep '^HTTP'
HTTP/1.1 204 No Content
~ ⮀ curl -siLn https://api.github.com/orgs/npm/members/itzmjauz | grep '^HTTP'
HTTP/1.1 404 Not Found
These two unauthenticated:
~ ⮀ curl -siL https://api.github.com/orgs/npm/members/nathan7 | grep '^HTTP'
HTTP/1.1 302 Found
HTTP/1.1 204 No Content
~ ⮀ curl -siL https://api.github.com/orgs/npm/members/itzmjauz | grep '^HTTP'
HTTP/1.1 302 Found
HTTP/1.1 404 Not Found
The GitHub API client you're using handles the redirect — all "not a member" paths return a 404.
Allow limiting authentication to members of a specific GitHub org
@@ -11,6 +11,7 @@ function AuthenticateGithub(opts) { | |||
debug: true, | |||
githubHost: config.githubHost, | |||
githubPathPrefix: '/api/v3', | |||
githubOrg: config.githubOrg, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's been a while, but would it be possible to extend it in order to support multiple organizations? Really don't want to come up with a fork of this repo just because of this restriction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
master...nathan7:multiple-github-orgs this would do the trick — any opinion on this, @bcoe?
This includes tests.