Feedemy.KeyManagement.Providers.Npgsql
3.3.1
dotnet add package Feedemy.KeyManagement.Providers.Npgsql --version 3.3.1
NuGet\Install-Package Feedemy.KeyManagement.Providers.Npgsql -Version 3.3.1
<PackageReference Include="Feedemy.KeyManagement.Providers.Npgsql" Version="3.3.1" />
<PackageVersion Include="Feedemy.KeyManagement.Providers.Npgsql" Version="3.3.1" />
<PackageReference Include="Feedemy.KeyManagement.Providers.Npgsql" />
paket add Feedemy.KeyManagement.Providers.Npgsql --version 3.3.1
#r "nuget: Feedemy.KeyManagement.Providers.Npgsql, 3.3.1"
#:package Feedemy.KeyManagement.Providers.Npgsql@3.3.1
#addin nuget:?package=Feedemy.KeyManagement.Providers.Npgsql&version=3.3.1
#tool nuget:?package=Feedemy.KeyManagement.Providers.Npgsql&version=3.3.1
Feedemy.KeyManagement
Enterprise-grade key management library for .NET applications.
Features
- Automatic Key Rotation - Background service with configurable intervals
- Versioned Encryption - Auto-decryption with version detection
- Asymmetric Keys - RSA (2048/3072/4096) and ECDSA (P-256/P-384/P-521)
- Multi-Platform Storage - Windows DPAPI, Linux Keyring, Azure Key Vault
- Distributed Caching - Redis with pub/sub invalidation
- Database Persistence - SQL Server, PostgreSQL, and SQLite
- Health Monitoring - ASP.NET Core health checks
- Fallback Storage - Multi-provider redundancy
- Audit Trail - Complete compliance logging
- Roslyn Analyzers - 48 compile-time security rules
Installation
dotnet add package Feedemy.KeyManagement
# Persistence (choose one)
dotnet add package Feedemy.KeyManagement.Providers.EntityFramework # SQL Server
dotnet add package Feedemy.KeyManagement.Providers.Npgsql # PostgreSQL
dotnet add package Feedemy.KeyManagement.Providers.Sqlite # SQLite (dev/testing)
# Optional
dotnet add package Feedemy.KeyManagement.Analyzers
Upgrading to 3.3.1? The Redis integration now builds on
StackExchange.Redis3.x (up from 2.x). If your application also referencesStackExchange.Redisdirectly, taking 3.3.1 pulls the v3 major into your dependency graph — pin the version explicitly if you are not ready for it. Full details in the CHANGELOG.
Quick Start
Development Setup
using Feedemy.KeyManagement.Extensions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddKeyManagement(options =>
{
options.EnableAutoRotation = true;
options.RotationCheckInterval = TimeSpan.FromHours(6);
options.DefaultRotationDays = 90;
});
var app = builder.Build();
app.Run();
Production Setup
builder.Services.AddKeyManagement(options =>
{
options.EnableAutoRotation = true;
options.RotationCheckInterval = TimeSpan.FromHours(6);
// Auto-initialization
options.Initialization.EnableAutoInitialization = true;
options.Initialization.ExternalKeysJsonPath = "keys.json";
})
.WithAzureKeyStorage("https://your-vault.vault.azure.net/")
.WithRedisCache("localhost:6379")
.WithSqlServerMetadata("Server=localhost;Database=KeyManagement;...");
builder.Services.AddHealthChecks()
.AddKeyManagementHealthCheck();
Basic Usage
public class MyService
{
private readonly IKeyManagementService _keyService;
private readonly IKeyManagementAdminService _adminService;
// Create a key
public async Task CreateKeyAsync()
{
await _adminService.CreateKeyAsync(new CreateKeyRequest
{
KeyName = "MyEncryptionKey",
AutoGenerate = true,
KeySize = 32,
RotationIntervalDays = 90,
CreatedBy = "Admin"
});
}
// Retrieve a key (cached - sub-millisecond)
public async Task<byte[]> GetKeyAsync()
{
return await _keyService.RetrieveKeyAsync("MyEncryptionKey");
}
// Check health
public async Task<KeyHealthStatus> GetHealthAsync()
{
var health = await _keyService.GetKeyHealthAsync("MyEncryptionKey");
return health.Status;
}
}
Key Initialization
Define keys in keys.json for auto-generation on first run:
{
"Keys": [
{
"KeyName": "EncryptionKey",
"KeyType": "Symmetric",
"RotationIntervalDays": 90,
"Category": "MasterKey"
},
{
"KeyName": "JwtSigningKey",
"KeyType": "RSA",
"KeySize": 2048,
"RotationIntervalDays": 180,
"Category": "Signing"
}
]
}
Asymmetric Keys
// Sign data
var signature = await _asymmetricOps.SignAsync(
"JwtSigningKey",
data,
HashAlgorithmName.SHA256);
// Verify signature
var isValid = await _asymmetricOps.VerifyAsync(
"JwtSigningKey",
data,
signature,
HashAlgorithmName.SHA256);
// Get public key for external use
var publicKeyPem = await _asymmetricOps.GetPublicKeyPemAsync("JwtSigningKey");
Performance
| Operation | Mean | Notes |
|---|---|---|
| RetrieveKey (cached) | < 1 μs | L1 cache hit |
| RetrieveKey (cache miss) | ~12 ms | Database + storage |
| Sign (RSA-2048) | ~1.2 ms | |
| Verify (RSA-2048) | ~0.15 ms | |
| Sign (ECDSA P-256) | ~0.35 ms | |
| Verify (ECDSA P-256) | ~0.12 ms |
Packages
| Package | Description |
|---|---|
Feedemy.KeyManagement |
Core library |
Feedemy.KeyManagement.Providers.EntityFramework |
SQL Server persistence |
Feedemy.KeyManagement.Providers.Npgsql |
PostgreSQL persistence |
Feedemy.KeyManagement.Providers.Sqlite |
SQLite persistence (dev/testing) |
Feedemy.KeyManagement.Analyzers |
Roslyn analyzers |
Documentation
Detailed documentation available in docs/partial/:
README_CORE.md- API referenceREADME_CONFIG.md- Configuration optionsREADME_STORAGE.md- Storage providersREADME_PERSISTENCE.md- Database setupREADME_CACHE.md- Caching architectureREADME_INIT.md- Initialization guideREADME_BACKGROUND.md- Background servicesREADME_EXTENSIONS.md- DI setup
License
This project is dual-licensed:
- MIT License - Free for all use cases including commercial
- Commercial License - For enterprise support, SLA, and priority features
| Use Case | License | Cost |
|---|---|---|
| Personal projects | MIT | Free |
| Open source projects | MIT | Free |
| Commercial products | MIT | Free |
| Enterprise support & SLA | Commercial | Paid |
Commercial inquiries: licensing@feedemy.com
Support
Copyright (c) 2025 Feedemy
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Feedemy.KeyManagement (>= 3.3.1)
- Microsoft.EntityFrameworkCore (>= 10.0.11)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.11)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 10.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.3.1 | 169 | 8/27/2026 |
| 3.3.0 | 359 | 6/11/2026 |
| 3.2.1 | 184 | 4/24/2026 |
| 3.2.0 | 113 | 4/24/2026 |
| 3.1.0 | 168 | 3/9/2026 |
| 3.0.6 | 117 | 3/9/2026 |
| 3.0.5 | 113 | 3/9/2026 |
| 3.0.4 | 117 | 3/9/2026 |
| 3.0.3 | 120 | 3/9/2026 |
| 3.0.2 | 122 | 3/9/2026 |
| 3.0.1 | 124 | 2/27/2026 |
| 2.5.10 | 284 | 1/21/2026 |
| 2.5.3 | 227 | 1/3/2026 |
| 2.5.2 | 711 | 12/1/2025 |
| 2.5.1 | 711 | 12/1/2025 |
v3.3.1 - Dependency maintenance
No provider code changed. Aligned to Feedemy.KeyManagement 3.3.1.
- Microsoft.EntityFrameworkCore.* 10.0.9 -> 10.0.11.
- Npgsql.EntityFrameworkCore.PostgreSQL 10.0.2 -> 10.0.3 (Npgsql provider).
- Core brings StackExchange.Redis 2.13.17 -> 3.1.31 (MAJOR) - see the core
package notes before upgrading.
----- Previous release -----
v3.0.0 - Major version alignment with Feedemy.KeyManagement 3.0.0
BREAKING CHANGES:
- Requires Feedemy.KeyManagement 3.0.0+ (not backward compatible with 2.x core)
- IKeyMetadataRepository: new required members (ExistsIncludingInactiveAsync, GetByKeyNameAsync)
- OperationResult<T> is now immutable (init-only properties)
UPDATED:
- EF Core unified to 10.0.1
- Npgsql.EntityFrameworkCore.PostgreSQL 10.0.0
- Target framework: .NET 10.0
- All repository implementations comply with v3.0.0 interface contracts
- SQL injection fix in DatabaseMigrator (parameterized queries via NpgsqlParameter)
SECURITY:
- CRITICAL: Fixed SQL injection in PostgreSQL DatabaseMigrator — version/description parameters now use NpgsqlParameter instead of string interpolation
- Parameterized SQL queries throughout
- CryptographicOperations.ZeroMemory patterns in key material handling
COMPATIBILITY:
- Requires Feedemy.KeyManagement 3.0.0+
- .NET 10.0
- PostgreSQL 12+
- Npgsql.EntityFrameworkCore.PostgreSQL 10.0.0