Skip to content

Instantly share code, notes, and snippets.

@jokeyrhyme
Created January 15, 2015 03:22
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 jokeyrhyme/571383317262303b27ce to your computer and use it in GitHub Desktop.
Save jokeyrhyme/571383317262303b27ce to your computer and use it in GitHub Desktop.
Hapi.js Authentication test
'use strict';
// 3rd-party modules
var Hapi = require('hapi');
// this module
var server = new Hapi.Server();
server.auth.scheme('custom', function (server, options) {
console.log('server.auth.scheme(): custom:');
return {
authenticate: function (request, reply) {
console.log('authenticate():');
reply.continue({ credentials: {} });
}
};
});
server.auth.strategy('default', 'custom', true);
server.auth.default('default');
server.connection({ port: 3000 });
server.start(function () {
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
console.log('server.route(): handler:');
reply('hello world');
}
});
console.log('info', 'Server running at: ' + server.info.uri);
});
@jokeyrhyme
Copy link
Author

When I execute this and make the HTTP request, I do not see any console messages from the scheme, only from the route. I can't seem to get the scheme to activate.

@jokeyrhyme
Copy link
Author

From IRC:

*\malex* jokeyrhyme: setup your connection before you define the strategy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment