hapi-strategy-loader
Hapi server plugin to configure your authentication strategies
AUsage:
To use hapi-strategy-loader, you will need to have at least one authentication strategy registered with your hapi server. This example will use hapi-auth-cookie to manage session authentication.
Install
At the command line do:
npm install hapi-strategy-loader
Set up your server and register an authentication strategy:
const Hapi = ;const hapiCookie = ; const server = ;server;// register your authentication strategies with hapi// don't worry about the config options yet:server;
Register the hapi-strategy-loader plugin with config options for your strategies:
// these are options recognized by hapi-auth-cookie: const hapiCookieOptions = cookie: 'some-cookie-identifier' ttl: 60 * 1000 domain: 'example.com' ; server;
You can now use the new auth scheme in your server's routes:
// this route will return 401 if the user's session isn't authenticated: server; // you can use this route to authenticate the user's session: server;
See the test/ folder for more working examples.