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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="IlyaKo.AspNet.SideAuth" Version="0.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IlyaKo.AspNet.SideAuth" Version="0.1.3" />
                    
Directory.Packages.props
<PackageReference Include="IlyaKo.AspNet.SideAuth" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add IlyaKo.AspNet.SideAuth --version 0.1.3
                    
#r "nuget: IlyaKo.AspNet.SideAuth, 0.1.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package IlyaKo.AspNet.SideAuth@0.1.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=IlyaKo.AspNet.SideAuth&version=0.1.3
                    
Install as a Cake Addin
#tool nuget:?package=IlyaKo.AspNet.SideAuth&version=0.1.3
                    
Install as a Cake Tool

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
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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