Skip to content

Sarmkadan/api-key-gateway

Repository files navigation

API Key Gateway

A lightweight, production-grade API key authentication gateway for self-hosted services.

Build Status License: MIT

Docker Usage

This project includes a docker-compose.yml file to run the gateway and its dependencies (SQL Server and Redis).

Start services

docker-compose up -d

View logs

docker-compose logs -f api-key-gateway

Stop services

docker-compose down

Installation

git clone https://github.com/sarmkadan/api-key-gateway.git
cd api-key-gateway
docker-compose up -d

Quick Start

// Example: Creating an API key
var key = await apiKeyService.CreateKeyAsync("consumer_001", "DevKey", expirationDays: 365);
Console.WriteLine($"Key: {key.Id}");

Examples

For more comprehensive usage scenarios, see the examples/ directory:

Configuration

Update appsettings.json with your SQL Server ConnectionStrings:DefaultConnection.

Benchmarks

This project includes a performance testing suite using BenchmarkDotNet to measure hot paths and critical operations.

Running Benchmarks

To run the full benchmark suite in Release mode:

dotnet run -c Release --project benchmarks/api-key-gateway.Benchmarks/api-key-gateway.Benchmarks.csproj

You 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 -- ApiKeyValidationBenchmarks

License

MIT - Copyright (c) 2026 Vladyslav Zaiets

About

Lightweight API key authentication gateway for self-hosted services - rate limiting, usage tracking

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors