Created
May 15, 2018 17:10
-
-
Save bcoe/d9b92a161eec2301334d49261aff658f to your computer and use it in GitHub Desktop.
github-access-control.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (user, context, callback) { | |
// We check users only authenticated with 'github' | |
if(context.connection === 'github'){ | |
var whitelist = [ | |
'bcoe', | |
'batman' | |
]; //authorized github accounts. | |
var userHasAccess = whitelist.some((name) => { | |
return name === user.nickname; | |
}); | |
if (!userHasAccess) { | |
return callback(new UnauthorizedError('Access denied.')); | |
} | |
} | |
callback(null, user, context); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment