Complete, compliant and well tested module for implementing an OAuth2 Server/Provider with Hapi in node.js.
This is the Hapi wrapper for oauth2-server.
// Not yet published :>
$ npm install Hapi-oauth-server
var Hapi = require('Hapi');
app = new hapi.Server();
app.connection({ port: 3000 });
app.register({register: plugin, options: {
model: {} // See https://github.com/thomseddon/node-oauth2-server for specification
}}, function (err) {
// Do smthing w/ the error :)
});
app.route({method: 'GET', path: '/authenticate', handler: {'oauth2-authenticate': {}}});
app.route({method: 'GET', path: '/authorize', handler: {'oauth2-authorize': {}}});
app.route({method: 'GET', path: '/token', handler: {'oauth2-token': {}}});var options = {
useErrorHandler: false, // Not yet tested from the express module
continueMiddleWare: false,
}
-
useErrorHandler(type: boolean default: false)If false, an error response will be rendered by this component. Set this value to true to allow your own Hapi error handler to handle the error.
-
continueMiddleware(type: boolean default: false)The
authorize()andtoken()middlewares will both render their result to the response and end the pipeline. next() will only be called if this is set to true.Note: You cannot modify the response since the headers have already been sent.
authenticate()does not modify the response and will always call next()
