NPv.Auth.AspNetCore
0.6.0
dotnet add package NPv.Auth.AspNetCore --version 0.6.0
NuGet\Install-Package NPv.Auth.AspNetCore -Version 0.6.0
<PackageReference Include="NPv.Auth.AspNetCore" Version="0.6.0" />
<PackageVersion Include="NPv.Auth.AspNetCore" Version="0.6.0" />
<PackageReference Include="NPv.Auth.AspNetCore" />
paket add NPv.Auth.AspNetCore --version 0.6.0
#r "nuget: NPv.Auth.AspNetCore, 0.6.0"
#:package NPv.Auth.AspNetCore@0.6.0
#addin nuget:?package=NPv.Auth.AspNetCore&version=0.6.0
#tool nuget:?package=NPv.Auth.AspNetCore&version=0.6.0
NPv.Auth.AspNetCore
ASP.NET Core host integration for NPv authentication realms.
The package provides Minimal API auth endpoints, secure auth-cookie handling,
claims helpers, and dependency-injection registration for the application
workflows in NPv.Auth.Application.
Status
This package is at an early stage (0.x). Its public API, endpoint routes, and
cookie behavior may change between minor versions.
Installation
dotnet add package NPv.Auth.AspNetCore
Register a realm during application startup and map its endpoints in the host:
services.AddAuthRealm<Account, EmailConfirmation, PasswordRecovery, RefreshToken>(
new AuthRealmOptions
{
Name = "admin",
Path = "/api/admin/auth",
ClientBaseUrl = "https://admin.example.com",
RefreshCookieName = "a_rt",
DeviceCookieName = "a_di"
});
app.MapAuthRealm<Account>();
The host remains responsible for authentication middleware, authorization, configuration values, persistence registration, and database migrations.
For custom entities, follow the Domain contract and EF contract. The example assumes these consumer-defined types and host dependencies exist.
Repeat registration and endpoint mapping for each distinct account type, using unique realm names and separate endpoint paths and cookie names. The registry requires unique account types and names; registering one account type under multiple names does not create separate user pools.
ConfigurationKey defaults to Name. AddAuthRealm binds registration options
from Auth:Realms:{ConfigurationKey}:Registration; the host supplies other
AuthRealmOptions values explicitly, including ClientBaseUrl. See the
Application README for email-link configuration.
Use AddAuthClaimsProvider<TAccount, TProvider>() to replace the default claims provider.
Starting with 0.5.0, AddAuthRealm also registers
ICommand<ProvisionConfirmedAuthAccountCommandContext<TAccount>> with
ProvisionConfirmedAuthAccountCommand<TAccount> as a transient service. The host
authorizes the caller and invokes it through the standard CQS/UoW executor; no
provisioning HTTP endpoint is mapped. This supports confirmed account creation
even when public registration is disabled. Dependencies and caller obligations
are defined in the Application provisioning contract.
Author's Note
This library grew out of my long-standing personal interest in structuring and publishing open source packages. Over time, I’ve revisited and refined earlier internal utilities and ideas, giving them a more consistent shape and preparing them for wider reuse. Along the way, I’ve also taken the opportunity to explore how open source distribution and licensing work in the .NET ecosystem.
It’s a small step toward something I’ve always wanted to try — sharing practical, minimal tools that reflect years of learning, experimentation, and refinement.
Hopefully, someone finds it useful.
Nikolai 😛
⚖️ License
MIT — you are free to use this in commercial and open-source software.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- NPv.AspNetCore.Endpoints (>= 0.2.0)
- NPv.Auth.Application (>= 0.5.0)
- NPv.Auth.Domain (>= 0.2.0)
- NPv.CQS.Abstractions (>= 3.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.