Installation
Prerequisites
The HUMAN Edgio Enforcer uses Node.js and Edgio’s Edge Functions. See the prerequesites for using Edge Functions here.
The Enforcer is supported for Edgio Core v7.x and Node.js 16.x.
Installation
Cookie V2
The Edgio Edge Function Enforcer uses Bot Defender Cookie V2. If you are unable to validate this by navigating to Bot Defender > Product Settings > Security Policy > Risk Cookie Key (Advanced Settings), please reach out to our support team.
- Create an Edgio property and router (if you haven’t already) by following the instructions here.
- Install the HUMAN Enforcer NPM package into your Edgio project.
- Modify the
edgio.config.js
file to include the following four origins, replacing<PX_APP_ID>
with your application ID (e.g.,PX12345678
). For more information on the Edgio configuration file, see here.
Origin Names
The default names of these origins are hs-sapi-origin
, hs-collector-origin
, hs-client-origin
, and hs-captcha-origin
. If the default hs-*-origin
origin names are changed, the new origin names must be explicitly indicated in the Enforcer configuration using the px_backend_origin_name
, px_backend_collector_origin_name
, px_backend_client_origin_name
, and px_backend_captcha_origin_name
configurations, respectively.
- Integrate the HUMAN Enforcer into your Edge Function’s main file.
For an out-of-the box handler with the HUMAN Enforcer integrated into it already, simply import and use the createEnforcedRequestHandler
function.
The example below shows what the createEnforcedRequestHandler()
function does behind the scenes. For a more customized solution, construct a new HumanSecurity
instance, create an enforcer, and use it in the handleHttpRequest
function.
The recommended usage is to:
- create the HUMAN enforcer, call the
enforce()
function, and return any resulting response as early as possible in the request flow to minimize invocation of unnecessary logic. - call the
postEnforce()
right before returning the response from the request handler to ensure any necessary response modifications are performed and HUMAN data is sent to the collector.
Using Fetch
See here for details on how to use Edgio’s built-in fetch
function to make requests to your origin server.
Edge Function Limitations
Be aware of Edgio’s Edge Function limitations when developing your edge function!
- Use the Edgio CLI to test your edge function locally and deploy the Edgio property.