If your organization uses Azure Front Door, you can use HUMAN’s Azure Front Door Enforcer to protect against malicious behavior, which dictates how traffic should be handled per your organization’s standards. The Azure Enforcer combines Azure’s Front Door CDN caching functionality with the Azure Function App’s ability to run serverless code in the cloud.

You can learn how to install the Azure Front Door Enforcer with this article.
If you do not already have an Enforcer deployed to your environment, we highly recommend using the Deploy Tool method instead. See our documentation for more information.
Microsoft.Cdn (for Front Door)Microsoft.Storage (for Storage Accounts)Microsoft.Sites (for App Service)Microsoft.Resources (for Resource Groups)Microsoft.Web (for Function Apps)In the Azure Portal, create a new Function App resource. Provide a name and resource group for the Function App.
Importing as SDK into an Existing Function App
If you’re utilizing the Functions App for processing HTTP requests from your Front Door already, you can install the Azure Enforcer as an SDK into your JavaScript project.
Refer to the API documentation and the example in the example folder of the library for how to best integrate with your project.
Creating a New Function
If you’re creating a brand new HTTP trigger function, use the Azure Enforcer template available in GitHub.
npm install.EnforcerFunction/config.json file with your desired configuration.npm run functionapp:compile.EnforcerFunction folder will contain the compiled index.js file that will be used for the Function App.You can deploy to Azure by running the Azure Functions Core Tools command to publish the Function App.
The Azure Enforcer also provides host.json and function.json files as examples of working Function App configurations. Feel free to use these JSONs as provided, or modify your existing Function App to conform to the following settings:
host.json file). See here for more information.{*route}, which translates to all routes (see the function.json file).function.json file).function.json file). This means invoking the function requires an API key. See here for more information.
Deploy the compiled JavaScript code to the Azure portal via the Azure Functions Core Tools, the Azure VS Code extension, or simply by copy-pasting these files to the new Function.
Add the origin groups with the origin host names below to your Azure Front Door. Each origin group can have a single origin.
client.perimeterx.netcaptcha.px-cdn.netcollector-<APP_ID>.perimeterx.net<FUNCTION_APP_NAME>.azurewebsites.netHealth probes and session affinity can be disabled for these origin groups as there is a single origin per group.

A Front Door Rule Set allows for changing the origin group of the incoming request based on certain parameters. The Rule Set for the Enforcer serves to proxy first party requests to the appropriate Human Security backend (HSClient, HSCaptcha, or HSCollector), as well as proxy unverified requests through the enforcer in the Function App. The Rule Set should contain the following rules in this order:


Stop evaluating remaining rules: True

Stop evaluating remaining rules: True

Stop evaluating remaining rules: True

Stop evaluating remaining rules: True

Stop evaluating remaining rules: True
x-enforcer-auth header is equal to some [SECRET_KEY]. This header signifies to Front Door that the request has been processed by the enforcer. The value can be configured to be whatever string you like; however, it must be configured identically in both the Front Door rule and the Function App.x-function-key header. This header is what allows Front Door to trigger the Function App. The [FUNCTIONS_KEY] value should be the Function App’s default function key. See the HTTP Trigger Authorization Levels for more information.This activates the Rule Set on the Front Door endpoint. For more information, see how to configure Front Door endpoints.
Add a new backend pool to your Azure Front Door setup. The backend pool should have a single backend host name that points to the Azure Function App.
<FUNCTION_APP_NAME>.azurewebsites.netHealth probe can be disabled for this backend pool as there is a single backend.

A Front Door Rules Engine allows for changing the backend pool of the incoming request based on certain parameters. Create a new Rules Engine named HSEnforcedRule.

This Rules Engine will proxy unverified requests through the enforcer in the Function App. It should include two rules in this order:

Stop evaluating remaining rules: True

x-enforcer-auth header is equal to some [SECRET_KEY]. This header signifies to Front Door that the request has been processed by the enforcer. The value can be configured to be whatever string you like; however, it must be configured identically in both the Front Door rule and the Function App.x-function-key header. This header is what allows Front Door to trigger the Function App. The [FUNCTIONS_KEY] value should be the Function App’s default function key. See the HTTP Trigger Authorization Levels for more information.The routing rule should direct whichever paths you want to protect to the origin backend pool. Associating the HSEnforcerRule Rule Set with the routing rule will ensure these requests pass through the enforcer Function App prior to reaching your origin.

