Installation
If your organization uses ASP.NET Core, you can use HUMAN’s .NET Core Enforcer to protect your application from malicious behavior. The Enforcer is installed as a NuGet package in an existing ASP.NET Core application and runs as middleware in the application’s request pipeline. It evaluates incoming requests and applies the handling configured for your HUMAN application.
If your application uses classic ASP.NET on .NET Framework rather than ASP.NET Core, we recommend using HUMAN’s ASP.NET Enforcer instead.
You can learn how to install the .NET Core Enforcer with this article.
Prerequisites
- .NET version 6.0 or higher. See Microsoft’s documentation for installation instructions.
- An existing ASP.NET Core project with a
.csprojfile. You’ll add HUMAN’s Enforcer as a NuGet middleware to this project. - (Optional) Visual Studio Code, where you can install the HUMAN Module extention with the NuGet package manager.
- Your unique HUMAN information:
- Your Application ID. You can find this under Platform Settings > Applications > Select an application > Application Settings > Application ID in the HUMAN console. If you have multiple environments, you will also have multiple Application IDs, so be sure to choose the correct ID for the environment you want to install on.
- Your Server Token. You can find this under Platform Settings > Applications > Select an application > Application Settings > Server Token.
- Your Risk Cookie Key. You can find this under Bot Defender > Policies > Policy Settings > Policy Information.
Install the HUMAN package
- In the CLI, navigate to the directory of your ASP.NET Core project that has the
.csprojfile. - Run the following command. Replace
<VERSION>with the latest version from the changelog:
Alternatively, in Visual Studio Code, you can select Project > Manage NuGet Packages, search for HumanModule, and install it.
- Restore and build the project:
Add required HUMAN configurations
Next, add the required HUMAN configurations to your project. You can also add any optional configurations in this step.
- Open your project’s JSON configuration file. This is named
appsettings.jsonby default. - Add a
HumanConfigurationsection to the root of the file, and update the fields with your Application ID, Risk Cookie Key, and Server Token respectively:
Update Program.cs
Finally, update your project’s Program.cs file to register HUMAN configuration and add the Enforcer middleware.
- Navigate to your project’s
Program.csfile. - Add the following
usingstatement:
- Before
builder.Build(), register the HUMAN configuration section:
- After building the app, add
UseHumanMiddleware()to the request pipeline. Place it after general request-processing middleware (for example, HTTPS redirection, static files, and routing) and before your application endpoints:
Your Program.cs should look similar to this:
Upgrading
To upgrade to the latest Enforcer version:
- In Visual Studio, right-click the solution and select Manage NuGet Packages for Solution.
- Search for
HumanModulein the Updates section, and update.
Or from the CLI: