Configuration Options

Configuring Required Parameters

Configuration options are set on the $perimeterxConfig variable.

Required parameters:

  • app_id
  • cookie_key
  • auth_token
  • module_mode

All parameters are obtainable via the HUMAN Portal. (Applications and Policies pages)

Changing the Minimum Score for Blocking

Default blocking value: 100

1$perimeterxConfig = [
2 ..
3 'blocking_score' => 75
4 ..
5]

Custom Blocking Actions

In order to customize the action performed on a valid block value, use the ‘custom_block_handler’ option, and provide a user-defined function.

The custom handler should contain the action to be taken, when a visitor receives a score higher than the ‘blocking_score’ value.
A common customization option can be supplying a custom branded block page.

Default block behaviour: return an HTTP status code of 403 and serve the HUMAN block page.

1/**
2 * @param \Perimeterx\PerimeterxContext $pxCtx
3 */
4$perimeterxConfig['custom_block_handler'] = function ($pxCtx)
5{
6 $block_score = $pxCtx->getScore();
7 $block_uuid = $pxCtx->getUuid();
8
9 // user defined logic goes here
10};
11
12$px = Perimeterx::Instance($perimeterxConfig);
13$px->pxVerify();
Examples

Serving a Custom HTML Page

1/**
2 * @param \Perimeterx\PerimeterxContext $pxCtx
3 */
4$perimeterxConfig['custom_block_handler'] = function ($pxCtx)
5{
6 $block_score = $pxCtx->getScore();
7 $block_uuid = $pxCtx->getUuid();
8 $full_url = $pxCtx->getFullUrl();
9
10 $html = '<div>Access to ' . $full_url . ' has been blocked.</div> ' +
11 '<div>Block reference - ' . $block_uuid . ' </div> ' +
12 '<div>Block score - ' . $block_score . '</div>';
13
14 //echo $html;
15 header("Status: 403");
16 die();
17};
18
19$px = Perimeterx::Instance($perimeterxConfig);
20$px->pxVerify();