crumb

CSRF crumb generation and validation for hapi.

Latest Version: 8.0.0
hapi-family
Installation:

npm: npm install @hapi/crumb

yarn: yarn add @hapi/crumb

Module Status:
Version License Node Dependencies Travis End of Life
8.0.0
hapi helmet github logo
BSD 12 Dependency Status Build Status

Usage

  const Hapi = require('@hapi/hapi');
  const Crumb = require('@hapi/crumb');

  const server = new Hapi.Server({ port: 8000 });

  (async () => {
    await server.register({
      plugin: Crumb,

      // plugin options
      options: {}
    });

    server.route({
      path: '/login',
      method: 'GET',
      options: {
        plugins: {
          // route specific options
          crumb: {}
        },
        handler(request, h) {
          // this requires to have a view engine configured
          return h.view('some-view');
        }
      }
    });
  })();

For a complete example see the examples folder.