crumb

CSRF crumb generation and validation for hapi.

Latest Version: 9.0.1
hapi-family
Installation:

npm: npm install @hapi/crumb

yarn: yarn add @hapi/crumb

Module Status:
Version License Node Dependencies CI
9.0.1
hapi helmet github logo
BSD 16, 18, 20 Dependency Status Build Status
8.0.1
hapi helmet github logo
BSD 16, 18, 20 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.