Installation
Supported versions
- .NET >= 6
Installation
To work with NuGet, as a package consumer or creator, you can use command-line interface (CLI) tools as well as NuGet features in Visual Studio.
You can choose one of the following ways:
Install and use a NuGet package in Visual Studio
Install HumanModule using the NuGet Packge Manager in Visual Studio:
- Select Project > Manage NuGet Packages.
- In the NuGet Package Manager page, choose nuget.org as the Package source.
- From the Browse tab, search for HumanModule, select HumanModule in the list, and then select Install.
Install and use a package with the dotnet CLI
To install HumanModule, run the following command:
dotnet add package HumanModule
Integration
Edit program.cs
Add Human Module
using human_module
Using ILoggerFactory (Optional)-
The middleware is designed to work with ILoggerFactory to provide flexibility. If you want to use your own logger using ILoggerFactory, register it in the service container before using the middleware:
builder.Services.AddSingleton<ILoggerFactory,LoggerFactoryExample>();
Using HttpClientFactory (Optional)-
The middleware is designed to work with IHttpClientFactory to manage HTTP client lifetimes.
If you want HttpClient to be managed using IHttpClientFactory for better resilience and performance, register it in Program.cs as follows:
builder.Services.AddHttpClient();
Use HumanModule as a Middleware in your application:
app.UseHumanMiddleware();
Add configuration section (configuration level)
builder.Services.Configure<EnforcerConfig>(builder.Configuration.GetSection("HumanConfiguration"));
Add site specific configuration (configuration level)
On your app configuration JSON file (Default file name appsettings.json), add the following section:
...
"HumanConfiguration": {
"px_app_id": "XXX",
"px_cookie_secret": "XXX",
"px_auth_token": "XXX",
Other Human configuration options...
}
Configuring Required Parameters
Configuration options are set in EnforcerConfig
Required parameters:
- px_app_id
- px_cookie_secret
- px_auth_token
Upgrading
To upgrade to the latest Enforcer version:
- In Visual Studio, right click on the solution and Select Manage NuGet packages for solution.
- Search for
HumanModule
in the updates section, and update.
Updated 5 days ago