Skip to content

Instantly share code, notes, and snippets.

@bcoe
Created May 15, 2018 17:10
Show Gist options
  • Save bcoe/d9b92a161eec2301334d49261aff658f to your computer and use it in GitHub Desktop.
Save bcoe/d9b92a161eec2301334d49261aff658f to your computer and use it in GitHub Desktop.
github-access-control.js
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