Installation

If your organization uses AWS HTTP API Gateway with a NodeJS Lambda integration, you can use the HUMAN API Gateway Enforcer to protect your API Gateway against malicious behavior. The HUMAN enforcer easily integrates into your existing AWS Lambda function.

Prerequisites

📘

Note

For the HUMAN AWS HTTP API Gateway Enforcer to be compatible with your AWS Lambda function integration, the AWS Lambda function must use v2 of the payload format structure.

Installation

  1. Install the Enforcer using NPM package in your project.
npm install @humansecurity/aws-api-gateway-enforcer
  1. Save your handler in a constant
import { APIGatewayProxyEventV2 } from 'aws-lambda';

const myHandler = (event: APIGatewayProxyEventV2): Promise<APIGatewayProxyStructuredResultV2> => {
    // ... original lambda handler code
}
  1. Export HUMAN Security's handler from your Lambda.
import { handler as humanSecurityHandler } from "@humansecurity/aws-api-gateway-enforcer";

const pxConfig = {
    onPass: myHandler,
    px_app_id: "<APP_ID>",
    px_cookie_secret: "<COOKIE_SECRET>",
    px_auth_token: "<AUTH_TOKEN>"
    // ...
};
export const handler = humanSecurityHandler(pxConfig);
  1. Deploy the AWS Lambda function and API Gateway.