A lightweight, production-grade API key authentication gateway for self-hosted services.
This project includes a docker-compose.yml file to run the gateway and its dependencies (SQL Server and Redis).
docker-compose up -ddocker-compose logs -f api-key-gatewaydocker-compose downgit clone https://github.com/sarmkadan/api-key-gateway.git
cd api-key-gateway
docker-compose up -d// Example: Creating an API key
var key = await apiKeyService.CreateKeyAsync("consumer_001", "DevKey", expirationDays: 365);
Console.WriteLine($"Key: {key.Id}");For more comprehensive usage scenarios, see the examples/ directory:
- BasicUsage.cs: Minimal setup and first call.
- AdvancedUsage.cs: Configuration, custom options, and error handling.
- IntegrationExample.cs: Wiring into ASP.NET Core DI container.
Update appsettings.json with your SQL Server ConnectionStrings:DefaultConnection.
This project includes a performance testing suite using BenchmarkDotNet to measure hot paths and critical operations.
To run the full benchmark suite in Release mode:
dotnet run -c Release --project benchmarks/api-key-gateway.Benchmarks/api-key-gateway.Benchmarks.csprojYou can also run specific benchmarks by passing the class name as an argument:
dotnet run -c Release --project benchmarks/api-key-gateway.Benchmarks/api-key-gateway.Benchmarks.csproj -- ApiKeyValidationBenchmarksMIT - Copyright (c) 2026 Vladyslav Zaiets