Skip to content

Latest commit

 

History

History
56 lines (34 loc) · 1.48 KB

hapi.md

File metadata and controls

56 lines (34 loc) · 1.48 KB

hapi

At the very beginning of your app.js file, add the following line:

require("@aikidosec/firewall"); // <-- Include this before any other code or imports

const Hapi = require("@hapi/hapi");

const server = Hapi.server({
  port: 3000,
  host: "localhost",
});

// ...

or ESM import style:

import "@aikidosec/firewall";

// ...

That's it! Your app is now protected by Aikido firewall.

If you want to see a full example, check our hapi sample app.

Blocking mode

By default, the firewall will run in non-blocking mode. When it detects an attack, the attack will be reported to Aikido and continue executing the call.

You can enable blocking mode by setting the environment variable AIKIDO_BLOCKING to true:

AIKIDO_BLOCKING=true node app.js

It's recommended to enable this on your staging environment for a considerable amount of time before enabling it on your production environment (e.g. one week).

Debug mode

If you need to debug the firewall, you can run your express app with the environment variable AIKIDO_DEBUG set to true:

AIKIDO_DEBUG=true node app.js

This will output debug information to the console (e.g. if the agent failed to start, no token was found, unsupported packages, ...).

Preventing prototype pollution

Aikido firewall can also protect your application against prototype pollution attacks.

Read Protect against prototype pollution to learn how to set it up.