HumanSecurityModule 0.13.0
See the version list below for details.
dotnet add package HumanSecurityModule --version 0.13.0
NuGet\Install-Package HumanSecurityModule -Version 0.13.0
<PackageReference Include="HumanSecurityModule" Version="0.13.0" />
<PackageVersion Include="HumanSecurityModule" Version="0.13.0" />
<PackageReference Include="HumanSecurityModule" />
paket add HumanSecurityModule --version 0.13.0
#r "nuget: HumanSecurityModule, 0.13.0"
#:package HumanSecurityModule@0.13.0
#addin nuget:?package=HumanSecurityModule&version=0.13.0
#tool nuget:?package=HumanSecurityModule&version=0.13.0
Human Security .Net Core Enforcer - Module
Latest stable version: [v0.13.0]
Dependencies
- [.NET >= 6]
Installation
To install Human_Security_Module, run the following command:
dotnet add package HumanSecurityModule
Integration
Edit program.cs
- Add Human Module
using HumanSecurityModule;
- Add
HumanSecurityModuleas a service to your web api app:
builder.Services.AddSingleton<HumanSecurityModule.HumanSecurityModule>(provider =>
{
EnforcerConfig enforcerConfig = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build().GetSection("HumanConfiguration").Get<EnforcerConfig>();
return new HumanSecurityModule.HumanSecurityModule(enforcerConfig);
});
- 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...
}
⚠️ If you do not wish to add the configuration for Human on your appsettings.json file, you can simply create an instance of
EnforcerConfigmanually and provide it to the module instead.
Configuring Required Parameters
Configuration options are set in EnforcerConfig
Required parameters:
- px_app_id
- px_cookie_secret
- px_auth_token
Using HumanSecurityModule in a controller
- Inject
HumanSecurityModuleto your controller, for example:
public class WeatherForecastController : ControllerBase
{
...
private readonly HumanSecurityModule.HumanSecurityModule _humanModule;
public WeatherForecastController(HumanSecurityModule.HumanSecurityModule humanModule)
{
_humanModule = humanModule;
}
...
- In the handler function you wish to use Human, create a new instance of
HumanRequestby either passing it thehttpContextor the different components individually, and then call theEnforcemethod as follows:
HumanRequest humanRequest = new HumanRequest(this.HttpContext);
EnforceResult res = await _humanModule.Enforce(humanRequest);
EnforceResult will always contain the IsValid property, which indicate whether the request is a valid one (not a bot) or not, in addition to the request context which contains additional data about the request.
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
HumanSecurityModulein the updates section, and update.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- IPAddressRange (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.