Skip to content
IlyaKoPublic

About

.NET library that secures technical and DevOps endpoints without deploying heavy identity systems

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SideAuth

SideAuth is a library for ASP.NET Core designed to help developers protect specific Minimal API endpoints with HTTP Basic Authentication or API Keys using minimal configuration.

While operational endpoints—such as OpenAPI/Swagger/Scalar specifications, Prometheus metrics, or health checks—are typically restricted or excluded from production environments, certain deployment scenarios require them to remain accessible but protected. This library allows developers to secure these specific routes with a few lines of code directly during endpoint mapping.

Usage

1. Install package

dotnet add package IlyaKo.AspNet.SideAuth

2. Register services

services.AddBasicSideAuth("admin", "SecurePassword123");
services.AddApiKeySideAuth("prometheus-token");

3. Configure pipeline

app.MapOpenApi().RequireBasicSideAuth();
app.MapScalarApiReference().RequireBasicSideAuth();
app.MapGet("/todos", async (ITodoService service) => await service.GetAll());
app.MapGet("/todos/{id:int}", async (int id, ITodoService service) => await service.GetByIdAsync(id));
app.MapGet("/metrics", () => "Metrics data").RequireApiKeySideAuth();
app.MapGet("/healthz", () => "Healthy").RequireAnySideAuth();

Result

Based on the configuration above:

  • OpenAPI specifications and Scalar UI require HTTP Basic Authentication (admin / SecurePassword123)
  • /metrics requires prometheus-token passed in the default X-API-Key header
  • /healthz accepts either HTTP Basic Authentication or the API Key
  • /todo endpoints remain public

About

.NET library that secures technical and DevOps endpoints without deploying heavy identity systems

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages