Created
January 15, 2015 03:22
-
-
Save jokeyrhyme/571383317262303b27ce to your computer and use it in GitHub Desktop.
Hapi.js Authentication test
This file contains 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
'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); | |
}); |
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
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.