IlyaKo.AspNet.SideAuth
0.1.3
dotnet add package IlyaKo.AspNet.SideAuth --version 0.1.3
NuGet\Install-Package IlyaKo.AspNet.SideAuth -Version 0.1.3
<PackageReference Include="IlyaKo.AspNet.SideAuth" Version="0.1.3" />
<PackageVersion Include="IlyaKo.AspNet.SideAuth" Version="0.1.3" />
<PackageReference Include="IlyaKo.AspNet.SideAuth" />
paket add IlyaKo.AspNet.SideAuth --version 0.1.3
#r "nuget: IlyaKo.AspNet.SideAuth, 0.1.3"
#:package IlyaKo.AspNet.SideAuth@0.1.3
#addin nuget:?package=IlyaKo.AspNet.SideAuth&version=0.1.3
#tool nuget:?package=IlyaKo.AspNet.SideAuth&version=0.1.3
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) /metricsrequiresprometheus-tokenpassed in the defaultX-API-Keyheader/healthzaccepts either HTTP Basic Authentication or the API Key/todoendpoints remain public
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
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 |
|---|---|---|
| 0.1.3 | 91 | 7/26/2026 |
| 0.1.2 | 91 | 7/26/2026 |
| 0.1.1 | 95 | 7/13/2026 |
| 0.1.0-local | 91 | 7/12/2026 |