HmacManager 2.10.0
dotnet add package HmacManager --version 2.10.0
NuGet\Install-Package HmacManager -Version 2.10.0
<PackageReference Include="HmacManager" Version="2.10.0" />
<PackageVersion Include="HmacManager" Version="2.10.0" />
<PackageReference Include="HmacManager" />
paket add HmacManager --version 2.10.0
#r "nuget: HmacManager, 2.10.0"
#:package HmacManager@2.10.0
#addin nuget:?package=HmacManager&version=2.10.0
#tool nuget:?package=HmacManager&version=2.10.0
HmacManager
HMAC request authentication for ASP.NET Core. Sign outgoing requests, verify incoming ones, or both — against named policies, with replay protection built in.
Targets net8.0 and net10.0.
Install
dotnet add package HmacManager
Verify incoming requests
AddHmac registers an authentication handler, so a request that fails
verification never reaches your endpoint.
builder.Services
.AddAuthentication()
.AddHmac(options =>
{
options.AddPolicy("MyPolicy", policy =>
{
policy.UsePublicKey(Guid.Parse("00000000-0000-0000-0000-000000000001"));
policy.UsePrivateKey("zvg29s2cQ4idOqbUJWETOw==");
policy.UseMemoryCache(maxAgeInSeconds: 300); // nonce / replay window
});
});
var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();
Sign outgoing requests
Attach the handler to a named HttpClient and every request it sends is
signed.
builder.Services
.AddHttpClient("api", client => client.BaseAddress = new Uri("https://api.example.com"))
.AddHmacHttpMessageHandler("MyPolicy");
Documentation
The full documentation lives at jzills.github.io/hmac-manager:
| Registration | AddHmacManager versus AddHmac, and schemes |
| Authorization | Requiring a specific policy or scheme per endpoint |
| Configuration binding | Policies from an IConfigurationSection |
| HttpClient | Automatic signing, and why to prefer it |
| Events | OnValidateKeys, OnAuthSuccess, OnAuthFailure |
| Dynamic policies | Policies from a database, or changed at runtime |
| Custom signing content | Replacing the default signing string |
| Logging | Categories, levels, and diagnosing a mismatch |
Concepts shared with the Kubernetes verifier and the TypeScript client — policies, schemes, signing content, nonce and replay — are documented once, under Concepts.
Logging at a glance
Every component writes to ILogger with no configuration required, and falls
back to NullLogger when logging is not set up. Event ids are stable across
releases and are listed in the
event reference.
{
"Logging": {
"LogLevel": {
"HmacManager": "Debug"
}
}
}
Private keys are never logged at any level, and a test asserts that over the full sign/verify path with every level enabled.
Source
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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. |
-
net10.0
- System.Runtime.Caching (>= 10.0.0)
-
net8.0
- System.Runtime.Caching (>= 8.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.