.NET Core configuration options

Browse available configuration options for the .NET Core Enforcer

Each Enforcer has a set of configuration options that control the Enforcer’s functionality and features. While some are required, many of these are optional configurations that you can use to customize the Enforcer’s behavior. You can reference available configurations with this article. Define .NET Core Enforcer configuration in the HumanConfiguration section of appsettings.json, or another configuration provider bound to EnforcerConfig.

While all Enforcers come with the same set of required configurations, the optional configurations available for each may differ. We recommend updating to the latest Enforcer version to ensure you have access to the latest features and configurations.

Example
1...
2"HumanConfiguration": {
3 "px_app_id": "<APPLICATION_ID>",
4 "px_auth_token": "<AUTH_TOKEN>",
5 "px_cookie_secret": "<COOKIE_SECRET>",
6 // Other optional HUMAN configurations
7}

Certain custom logic options can’t be set in the configuration file. Instead, implement the corresponding HUMAN interface in your ASP.NET Core project, put your logic in that class’ Handle method, and set the configuration value to the class name. The Enforcer loads that class at startup. The relevant custom options have a Handler implementation example included.

Handler classes other than the custom filter must provide a public parameterless constructor. For custom filters, register the class in the ASP.NET Core service container so the Enforcer can resolve it with dependency injection.

Quick reference

Feature nameKeyTypeDefaultDescription
Application IDpx_app_idString""HUMAN Application ID
Authentication tokenpx_auth_tokenString""HUMAN authentication token
Cookie secretpx_cookie_secretString""HUMAN cookie secret
Backend domainpx_backend_urlStringhttps://sapi-{0}.perimeterx.netDomain to which HUMAN requests are sent. {0} is replaced with the application ID.
S2S timeoutpx_s2s_timeoutInteger1000Total time, in milliseconds, that the Enforcer will wait for the Risk API request to return before timing out and passing the request
Blocking scorepx_blocking_scoreInteger1000-100. The minimum risk score that the Enforcer blocks from.
Max user agent lengthpx_user_agent_max_lengthInteger8528Maximum length of a user agent. The default value is the current value used by the Collector to truncate the user agent. This configuration should only be modified if it’s also modified in the Collector
Max risk cookie lengthpx_risk_cookie_max_lengthInteger2048Maximum length of a risk cookie. The default value is the current value used by the Collector to truncate the risk cookie. This configuration should only be modified if it’s also modified in the Collector
Min risk cookie iterationspx_risk_cookie_min_iterationsInteger500Minimum number of iterations for the risk cookie V3.
Max risk cookie iterationspx_risk_cookie_max_iterationsInteger5000Maximum number of iterations for the risk cookie V3.

Required configurations

These configurations are necessary for the Enforcer’s basic functionality and features.

Basic functionality configurations

px_app_id
stringRequired

Your HUMAN Application ID in the form of PX12AB34CD. You can copy this value from the HUMAN Console in Platform Settings > Applications Overview. If you have multiple applications, make sure to copy the ID of the application you want the Enforcer on.

Example
1{
2 "px_app_id": "<APP_ID>"
3}
px_auth_token
stringRequired

The application’s server token needed to authorize with HUMAN’s backend. You can copy this value from the HUMAN Console in Platform Settings > Applications Overview > Click the appropriate application > Server token tab.

Example
1{
2 "px_auth_token": "<AUTH_TOKEN>"
3}
stringRequired

The secret used to encrypt and decrypt the risk cookie sent from the HUMAN Sensor. You can copy this value from the HUMAN Console in Sightline Cyberfraud Defense > Traffic Policy Overview > Click the appropriate application > Click the key > Copy value.

Example
1{
2 "px_cookie_secret": "<COOKIE_SECRET>"
3}
px_backend_url
stringDefaults to https://sapi-{0}.perimeterx.netRequired

Do not set this value unless directed by your HUMAN Solutions Engineer.

The base URL for the HUMAN SAPI (Risk API and related calls). If empty, the Enforcer uses the default host for your Application ID.

The default value uses {0} as a placeholder for your application ID.

Example
1{
2 "px_backend_url": "https://sapi-{0}.perimeterx.net"
3}
px_s2s_timeout
integerDefaults to 1000Required

The total time in milliseconds that the Enforcer will wait for the Risk API request to return before timing out and passing the request.

Example
1{
2 "px_s2s_timeout": 2000
3}
px_blocking_score
integerDefaults to 100Required

The minimum risk score that the Enforcer will block. Ranges from 0 (lowest risk) to 100 (highest risk).

Example
1{
2 "px_blocking_score": 100
3}
px_user_agent_max_length
integerDefaults to 8528Required

Do not modify this value without consulting your HUMAN Solutions Engineer.

The maximum length of the User-Agent header. If the user agent header value exceeds this length, it will be truncated to this length prior to processing.

Example
1{
2 "px_user_agent_max_length": 8528
3}
integerDefaults to 2048Required

The maximum length of the risk cookie. If the value exceeds this length, then validation will fail automatically.

Example
1{
2 "px_risk_cookie_max_length": 2048
3}
integerDefaults to 500Required

The minimum accepted number of iterations for the Risk Cookie V3.

Example
1{
2 "px_risk_cookie_min_iterations": 500
3}
integerDefaults to 5000Required

The maximum accepted number of iterations for the Risk Cookie V3.

Example
1{
2 "px_risk_cookie_max_iterations": 5000
3}

Basic feature configurations

px_logger_severity
"none" | "error" | "debug"Defaults to "error"Required

The severity at which the logger will output logs.

  • none: The logger will not generate any logs.
  • error: The logger will only generate logs on fatal errors.
  • debug: The logger will generate detailed logs for debugging purposes. Not recommended for production environments.

See px_logger_auth_token for a header-based alternative.

Example
1{
2 "px_logger_severity": "debug"
3}
px_logger_auth_token
stringDefaults to ""

An alternative to the basic logger configuration. This sends Enforcer logs to HUMAN’s logging service if a specific header is present on the request. This is particularly useful for expedited debugging, diagnosis, and resolution of any integration or Enforcer-related issues.

Contact HUMAN to recieve your token.

Example
1{
2 "px_logger_auth_token": "<LOGGER_AUTH_TOKEN>"
3}
px_ip_headers
string[]Defaults to []Required

An array of header names that are trusted to contain the true client IP. Headers are traversed in the order they’re listed, and the first header value will always be used as the client IP.

Taken from HttpContext.Connection.RemoteIpAddress by default.

If px_ip_extraction_handler returns a value, that value is used instead of these headers.

Example
1{
2 "px_ip_headers": ["true-ip", "true-client-ip"]
3}
px_ip_extraction_handler
stringDefaults to ""

A custom class that extracts the client IP. Set this value to the class name of an ICustomIpExtraction implementation. When the handler returns a non-null value, that value is used as the client IP. Otherwise, the Enforcer falls back to px_ip_headers, then to HttpContext.Connection.RemoteIpAddress.

The custom logic resides in the Handle method:

Returns: The client IP string, or null to fall back to header and connection-based extraction.

1{
2 "px_ip_extraction_handler": "CustomIpExtractionImpl"
3}
px_module_enabled
booleanDefaults to trueRequired

Whether the Enforcer module is enabled.

  • true: Enable the module
  • false: Disable the module
Example
1{
2 "px_module_enabled": true
3}
px_module_mode
"monitor" | "active_blocking"Defaults to monitorRequired

The Enforcer’s operation mode.

  • monitor: The Enforcer performs all functions without returning block responses. Useful for analyzing and adjusting Enforcer behavior without serving block pages to end users. If you have routes that must have enforcement at all times, see Enforced routes.
  • active_blocking: The Enforcer will return block responses as needed.
Example
1{
2 "px_module_mode": "active_blocking"
3}

Optional configurations

These configurations aren’t required, but you can use them to further customize the Enforcer’s behavior.

Additional activity handler

px_additional_activity_handler
stringDefaults to ""

A custom class the Enforcer invokes after the Risk API call and before it sends page_requested or block activity. A common use case is to set the score as a request header so the application can read it.

Set this value to the class name of an IAdditionalActivityHandler implementation. The class must provide a public parameterless constructor. The Enforcer calls Handle with:

Parameters:

  • httpRequest: The current ASP.NET Core HttpRequest
  • configuration: The current EnforcerConfig
  • context: The Enforcer Context, including fields such as score, uuid, blockAction, and riskApiData

Returns: void

1{
2 "px_additional_activity_handler": "CustomAdditionalActivityImpl"
3}

Advanced blocking response (ABR)

px_advanced_blocking_response_enabled
booleanDefaults to true

In specific cases such as XHR post requests, a full CAPTCHA page render might not be an option. In such cases, the Advanced Blocking Response (ABR) returns a JSON object containing all the information needed to render a customized CAPTCHA challenge implementation such as a popup modal, a section on the page, etc. This provides more flexibility and customizability in displaying the CAPTCHA challenge.

  • true: Enable ABR
  • false: Disable ABR

ABR is used when this configuration is true and the request Accept header includes application/json. The Enforcer then returns a JSON block payload instead of an HTML challenge page. A sample JSON response appears as follows:

Example
1{
2 "px_advanced_blocking_response_enabled": true
3}

Bypass monitor header

px_bypass_monitor_header
stringDefaults to x-px-block

Activates the full blocking flow to verify the flow works as expected if the specified header is present on the request with a value of 1. Often used to test the Enforcer block workflow during monitor mode, where the Enforcer usually collects data without blocking user requests, before switching to active_blocking. Requests with this header will go through the entire blocking workflow despite being in monitor mode.

To disable blocking behavior on the specified header, set the value to 0.

Example
1{
2 "px_bypass_monitor_header": "x-px-block"
3}
stringDefaults to x-px-cookies

By default, the Enforcer extracts HUMAN cookies from the Cookie header. However, if these cookies are transferred on a different header, then that header’s name must be provided with this configuration.

Example
1{
2 "px_custom_cookie_header": "x-px-cookies"
3}

Custom first party endpoints

These configurations let you use the Enforcer as a proxy for HUMAN servers and serve content to the browser from a first party endpoint. These are particularly useful when browser or extension restrictions that block JavaScript requests to other domains, such as adblockers, prevent the HUMAN Sensor from making requests to HUMAN’s backend. When this happens, it significantly limits HUMAN’s detection capabilities, so we recommend enabling these configurations to maintain full detection capabilities.

px_first_party_enabled
booleanDefaults to true

Whether to enable first party mode for Bot Defender or Sightline Cyberfraud Defense.

Example
1{
2 "px_first_party_enabled": true
3}
px_custom_first_party_prefix
string

Sets a custom prefix for first party routes to use in addition to the default prefix. By default, first party endpoints always begin with the Application ID without the initial “PX”. For example, if the ID is PX12345678, then all first party routes will take the form /12345678/*.

When configured, the Enforcer will respond to first party requests with endpoints matching the following patterns:

  • /<px_custom_first_party_prefix>/init.js
  • /<px_custom_first_party_prefix>/xhr/*
  • /<px_custom_first_party_prefix>/captcha/*

If empty, the configuration will use the default as described above.

Example
1{
2 "px_custom_first_party_prefix": "/custom-prefix"
3}
px_custom_first_party_sensor_endpoint
string

Customizes the entire first party Sensor script endpoint. By default, for an Application ID PX12345678, the first party endpoint is /12345678/init.js.

In addition to responding to requests that match this configured route, the Enforcer will also proxy first party requests that match the default pattern (/12345678/init.js) and patterns according to the custom prefix (/<px_custom_first_party_prefix>/init.js) if one is configured.

Example
1{
2 "px_custom_first_party_sensor_endpoint": "/human_sensor/init.js"
3}
px_custom_first_party_xhr_endpoint
string

Customizes the first party XHR endpoint. By default, for an Application ID PX12345678, the first party XHR endpoint is /12345678/xhr.

In addition to responding to requests that match this configured route, the Enforcer will also proxy first party requests that match the default pattern (/12345678/xhr/*) and patterns according to the custom prefix (/<px_custom_first_party_prefix>/xhr/*) if one is configured.

Example
1{
2 "px_custom_first_party_xhr_endpoint": "/human_xhr"
3}
px_custom_first_party_captcha_endpoint
string

Customizes the first party CAPTCHA endpoint. By default, for an Application ID PX12345678, the first party CAPTCHA endpoint is /12345678/captcha.

In addition to responding to requests that match this configured route, the Enforcer will also proxy first party requests that match the default pattern (/12345678/captcha/*) and patterns according to the custom prefix (/<px_custom_first_party_prefix>/captcha/*) if one is configured.

Example
1{
2 "px_custom_first_party_captcha_endpoint": "/human_captcha/captcha.js"
3}
px_first_party_timeout
integerDefaults to 4000

The maximum time in milliseconds to wait for first party requests.

Example
1{
2 "px_first_party_timeout": 4000
3}

Custom parameters

These configurations are related to custom parameters.

px_enrich_custom_params
stringDefaults to ""

Enriches activities sent from the Enforcer to HUMAN with additional custom parameters. This data can include user information, session IDs, or other data that HUMAN should have access to. There is a limit of 10 custom parameters (custom_param1 through custom_param10).

Set this value to the class name of an ICustomParameters implementation. The class must provide a public parameterless constructor.

Parameters:

Returns: A CustomParameters object.

1{
2 "px_enrich_custom_params": "CustomParametersImpl"
3}

Enforced routes

These configurations let you define specific routes that should be enforced by HUMAN when the Enforcer is in monitor mode. These routes will always be subject to the full Enforcer workflow, including blocking requests if necessary.

Primitive string values are treated as path prefixes. For example, /login also matches /login/callback.

px_enforced_routes
array of stringsDefaults to []

Routes or prefixes that should be enforced by HUMAN even when the Enforcer is in monitor mode.

Example
1{
2 "px_enforced_routes": ["/login", "/checkout"]
3}
px_enforced_routes_regex
array of stringsDefaults to []

Regular expressions for routes that should be ignored by the Enforcer.

Example
1{
2 "px_enforced_routes_regex": ["^/home$", "^/user.*"]
3}

Filters

These configurations let you filter out certain requests or assets from the Enforcer. These values will be ignored by the Enforcer and will never be blocked.

px_filter_by_extension
array of stringsDefaults to [ '.css', '.bmp', '.tif', '.ttf', '.docx', '.woff2', '.js', '.pict', '.tiff', '.eot', '.xlsx', '.jpg', '.csv', '.eps', '.woff', '.xls', '.jpeg', '.doc', '.ejs', '.otf', '.pptx', '.gif', '.pdf', '.swf', '.svg', '.ps', '.ico', '.pls', '.midi', '.svgz', '.class', '.png', '.ppt', '.mid', '.webp', '.jar', '.json', '.xml' ]

Filters out requests with the specified file extension. By default, HUMAN doesn’t enforce static assets such as images and documents to minimize unncessary API calls and computation, but you can configure this list at any time.

Filtering by extension only applies to GET and HEAD HTTP methods.

Example
1{
2 "px_filter_by_extension": [".css", ".js", ".png"]
3}
px_filter_by_http_method
array of stringsDefaults to []

Filters out requests with the specified HTTP method to avoid unnecessary traffic in the Enforcer verification flow.

Example
1{
2 "px_filter_by_http_method": ["OPTIONS", "DELETE"]
3}
px_filter_by_ip
array of stringsDefaults to []

Filters out requests with the specified IP address to avoid unnecessary traffic in the Enforcer verification flow.

Example
1{
2 "px_filter_by_ip": ["1.1.1.1", "2.2.2.2/8"]
3}
px_filter_by_route
array of stringsDefaults to []

Filters out requests with the specified route to avoid unnecessary traffic in the Enforcer verification flow. Requests to these specified routes will never be blocked regardless of their risk score and will never generate risk or async activities. Primitive string values are treated as path prefixes. For example, /login also matches /login/callback.

Example
1{
2 "px_filter_by_route": ["/contact-us", "/static"]
3}
px_filter_by_route_regex
array of stringsDefaults to []

Regular expressions for routes that should be filtered to avoid unnecessary traffic in the Enforcer verification flow. Requests to these specified routes will never be blocked regardless of their risk score and will never generate risk or async activities.

Example
1{
2 "px_filter_by_route_regex": ["^/contact-us.*", "^/user/.*"]
3}
px_filter_by_user_agent
array of stringsDefaults to []

Filters out requests with the specified user agent to avoid unnecessary traffic in the Enforcer verification flow. Primitive string values are case-sensitive and require an exact user-agent string.

Example
1{
2 "px_filter_by_user_agent": ["testUserAgent/v1.0", "ExampleBot"]
3}
px_filter_by_custom_function
stringDefaults to ""

This configuration is meant for cases that require more complex logic. We recommend you use the other default filters available for most cases.

A custom class that lets you define which requests should be filtered. Set this value to the class name of an ICustomFilter implementation. Return true to filter the request (Bot Defender detection is not applied). Return false to continue enforcement.

Register the implementation in the ASP.NET Core service container so the Enforcer can resolve it with dependency injection. If the type is not registered, the Enforcer falls back to a public parameterless constructor.

Parameters:

Returns: bool

1{
2 "px_filter_by_custom_function": "CustomFilterImpl"
3}

HUMAN Challenge customization

These configurations let you customize the HUMAN Challenge block page.

px_css_ref
string

A way to include a custom CSS file to the block page.

Example
1{
2 "px_css_ref": "https://www.example.com/custom_style.css"
3}
px_js_ref
string

A way to include custom JavaScript to the block page. This script will run after the default JavaScript scripts.

Example
1{
2 "px_js_ref": "https://www.example.com/custom_script.js"
3}
stringDefaults to ""

Adds a custom logo to the HUMAN Challenge block page via URL.

Example
1{
2 "px_custom_logo": "https://www.example.com/custom_logo.png"
3}

Monitored routes

These configurations let you specify routes that should be monitored by the Enforcer, which means their requests will never be blocked, even when the Enforcer is in active_blocking mode. This means that these routes will go through the full Enforcer workflow and generate risk and async activities, but all block activities will only be simulated blocks on these routes.

Primitive string values are treated as path prefixes. For example, /login also matches /login/callback.

px_monitored_routes
array of stringsDefaults to []

A list of endpoints to be monitored rather than blocked by the Enforcer, even when the Enforcer is in active_blocking mode.

Example
1{
2 "px_monitored_routes": ["/home", "/preview"]
3}
px_monitored_routes_regex
array of stringsDefaults to []

Regular expressions for routes that should be treated as monitored even when the Enforcer is in active_blocking mode.

Example
1{
2 "px_monitored_routes_regex": ["^/home$", "^/user.*"]
3}

Sensitive headers removal

px_sensitive_headers
string[]Defaults to ["cookie", "cookies"]

Specifies certain headers that should not be forwarded to any other destination, including the HUMAN Detector. While HUMAN’s detection system will continue to use these headers to determine whether to block or not, the specified headers won’t be forwarded from the Enforcer, won’t appear in Enforcer activities, and won’t be sent to any other IP if the Enforcer acts as a proxy.

Example
1{
2 "px_sensitive_headers": ["cookie", "cookies", "x-sensitive-token"]
3}

Sensitive routes

These configurations let you specify certain routes that need particularly stringent protection from attacks, such as endpoints that execute payments or handle personal information. Sensitive routes will always trigger a Risk API call even if the request contains a valid, unexpired, low-score cookie.

Primitive string values are treated as path prefixes. For example, /login also matches /login/callback.

Requests with high-score cookies won’t send a Risk API call.

px_sensitive_routes
array of stringsDefaults to []

A list of prefixes for all routes that should be considered sensitive.

Example
1{
2 "px_sensitive_routes": ["/login", "/checkout"]
3}
px_sensitive_routes_regex
array of stringsDefaults to []

A list of regular expressions for all routes that should be considered sensitive.

Example
1{
2 "px_sensitive_routes_regex": ["^/login$", "^/api/.*/checkout$"]
3}

Users identifiers

These configurations let you extract user identifiers from a JWT carried on the request either in a cookie or a header. They’re closely related to the Accounts and Account Takeover or Fake Account features in Sightline Cyberfraud Defense.

The Enforcer reads the JWT from the configured cookie first, then from the configured header if cookie extraction does not succeed. Field names support dot notation for nested JWT claim (for example, product.id).

stringDefaults to ""

The name of the cookie that contains the JWT token that HUMAN should extract user identifiers from.

Example
1{
2 "px_jwt_cookie_name": "auth"
3}
stringDefaults to ""

The field name in the JWT object, extracted from the JWT cookie, that contains the user ID to be extracted and reported.

Example
1{
2 "px_jwt_cookie_user_id_field_name": "nameID"
3}
string[]Defaults to []

The field names in the JWT object, extracted from the JWT cookie, that should be extracted and reported in addition to the user ID.

Example
1{
2 "px_jwt_cookie_additional_field_names": ["exp", "iss"]
3}
px_jwt_header_name
stringDefaults to ""

The name of the header that contains the JWT token that HUMAN should extract user identifiers from.

Example
1{
2 "px_jwt_header_name": "x-jwt-authorization"
3}
px_jwt_header_user_id_field_name
stringDefaults to ""

The field name in the JWT object, extracted from the JWT header, that contains the user ID to be extracted and reported.

Example
1{
2 "px_jwt_header_user_id_field_name": "sub"
3}
px_jwt_header_additional_field_names
string[]Defaults to []

The field names in the JWT object, extracted from the JWT header, that should be extracted and reported in addition to the user ID.

Example
1{
2 "px_jwt_header_additional_field_names": ["exp", "iss"]
3}