Secure Your ASP.NET Core APIs with Custom Key-Based Authentication
This middleware implementation provides a lightweight yet robust authentication layer for ASP.NET Core applications where traditional OAuth or JWT solutions may be overkill. Perfect for internal microservices, administrative endpoints, or third-party integrations that require simple but effective access control.
Enterprise-Ready Security Made Simple
- Zero-Configuration Authentication: Drop-in middleware that secures your endpoints immediately without complex setup or external dependencies
- Developer-Friendly Integration: Seamlessly integrates into existing
ASP.NETCore applications with just a few lines of code - no architectural changes required - Production-Tested Reliability: Battle-tested solution perfect for high-traffic microservices, internal tooling, and rapid prototype-to-production scenarios
git clone https://github.com/ejimeoghenefejiro/WebAPIKeyAuth.git
cd WebAPIKeyAuth- Configure the API Key Set the expected API key in appsettings.json:
{
"ApiKey": "your-secure-api-key"
}- Use the Middleware Register the middleware in your Program.cs or Startup.cs:
app.UseMiddleware<ApiKeyMiddleware>();Example Request
GET /weatherforecast HTTP/1.1
Host: localhost:5000
X-API-KEY: your-secure-api-keyRunning the Project
dotnet runπ€ Contributing
Contributions and stars are welcome! β Feel free to fork the repo and submit a pull request.