Skip to content

Instantly share code, notes, and snippets.

@vdeturckheim
Created April 10, 2016 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdeturckheim/f84a17b29743148700d9a5cd364b5aa5 to your computer and use it in GitHub Desktop.
Save vdeturckheim/f84a17b29743148700d9a5cd364b5aa5 to your computer and use it in GitHub Desktop.
'use strict';
const Bell = require('bell');
const AuthBearer = require('hapi-auth-bearer-token');
const AuthService = require('./lib/services/auth.service');
const Routes = require('./lib').routes;
exports.register = function (server, options, next) {
if (!options.github){
return next(new Error('no options provided for github'));
}
const ghOptions = options.github;
ghOptions.scope = ['user:email', 'gist'];
ghOptions.provider = 'github';
server.register([Bell, AuthBearer])
.then(() => {
server.auth.strategy('github', 'bell', ghOptions);
server.auth.strategy('bearer', 'bearer-access-token', {
allowQueryToken: false,
validateFunc: AuthService.validateToken
});
server.auth.default('bearer');
})
.then(() => {
server.route(Routes);
})
.then(() => next())
.catch((err) => next(err));
};
exports.register.attributes = {
pkg: require('./package.json')
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment