Zonit.Extensions.Auth
10.0.0-preview.2
See the version list below for details.
dotnet add package Zonit.Extensions.Auth --version 10.0.0-preview.2
NuGet\Install-Package Zonit.Extensions.Auth -Version 10.0.0-preview.2
<PackageReference Include="Zonit.Extensions.Auth" Version="10.0.0-preview.2" />
<PackageVersion Include="Zonit.Extensions.Auth" Version="10.0.0-preview.2" />
<PackageReference Include="Zonit.Extensions.Auth" />
paket add Zonit.Extensions.Auth --version 10.0.0-preview.2
#r "nuget: Zonit.Extensions.Auth, 10.0.0-preview.2"
#:package Zonit.Extensions.Auth@10.0.0-preview.2
#addin nuget:?package=Zonit.Extensions.Auth&version=10.0.0-preview.2&prerelease
#tool nuget:?package=Zonit.Extensions.Auth&version=10.0.0-preview.2&prerelease
Zonit.Extensions.Auth
Authentication / authorization plug-in for ASP.NET Core, integrated with the standard Microsoft authorization pipeline (AddAuthorization, [Authorize], IAuthorizationService, <AuthorizeView>) and extended with VO-typed permission and role attributes.
dotnet add package Zonit.Extensions.Auth
What you get
- A cookie-based authentication scheme
"Zonit"that turns theSessioncookie into aClaimsPrincipalviaIdentityClaimsBuilder. [RequirePermission("orders.read")]and[RequireRole("admin")]— built on .NET 8+IAuthorizationRequirementData, no manual policy registration inAddAuthorization.PermissionandRolevalue-object aware authorization handlers (with wildcards, e.g.orders.*).IAuthenticatedProvider.Currentreturning a lightweightIdentityVO (Id + Name + Roles + Permissions).- A scoped
IAuthenticatedRepositorythat theSessionMiddlewarepopulates once per request / circuit. - Cascading authentication state for Blazor.
Setup
// Program.cs
builder.Services.AddAuthExtension();
var app = builder.Build();
app.UseAuthExtension(); // UseAuthentication → UseAuthorization → SessionMiddleware
Implement ISessionProvider in your app (translate the cookie value into an Identity):
internal sealed class MyDbSessionProvider(MyDb db) : ISessionProvider
{
public async Task<Identity> GetByTokenAsync(string token, CancellationToken ct)
{
var s = await db.Sessions.Include(x => x.User)
.ThenInclude(u => u.Roles)
.FirstOrDefaultAsync(x => x.Token == token, ct);
if (s is null || s.ExpiresAt < DateTime.UtcNow) return Identity.Empty;
return new Identity(
id: s.User.Id,
name: new Title(s.User.DisplayName),
roles: s.User.Roles.Select(r => new Role(r.Name)),
permissions: s.User.Permissions.Select(p => Permission.Create(p)));
}
}
builder.Services.AddScoped<ISessionProvider, MyDbSessionProvider>();
Declarative authorization
// Controllers
[RequirePermission("orders.write")]
public IActionResult Update(...) => ...;
// Minimal API
app.MapGet("/admin", () => "ok")
.RequireAuthorization(new RequirePermissionAttribute("admin.*"));
// Razor / Blazor pages
@attribute [RequirePermission("orders.read")]
// Components
<AuthorizeView Policy="@(new RequirePermissionAttribute("orders.read").Policy)">
<Authorized>...</Authorized>
<NotAuthorized>403</NotAuthorized>
</AuthorizeView>
Wildcards: a user holding orders.* satisfies [RequirePermission("orders.read")] automatically — the comparison goes through Permission.Implies.
Reading the current identity
@inject IAuthenticatedProvider Auth
@if (Auth.IsAuthenticated)
{
<p>Hello, @Auth.Current.Name</p>
}
Or via the standard AuthenticationStateProvider / [CascadingParameter] Task<AuthenticationState> — the same principal is built via IdentityClaimsBuilder, so cookie-based and circuit-based paths are 1:1.
Claim shape (for advanced consumers)
| Claim type | Source |
|---|---|
ClaimTypes.NameIdentifier |
Identity.Id |
ClaimTypes.Name |
Identity.Name (skipped when empty) |
ClaimTypes.Role |
one per Identity.Roles |
zonit:permission |
one per Identity.Permissions (literal token, wildcards preserved) |
The permission claim type is a constant: IdentityClaimsBuilder.PermissionClaimType.
What this package does NOT do
- It does not provide login UI, password hashing, MFA or session storage. Those are the consumer's concern. The package only exposes the contract (
ISessionProvider). - It does not check authorization itself in
IWorkspaceProvider/ICatalogProvider. Those are pure tenant context — authorization is one place, not two.
License
MIT.
| 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
- Zonit.Extensions (>= 10.0.0-preview.2)
- Zonit.Extensions.Cultures (>= 10.0.0-preview.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Zonit.Extensions.Auth:
| Package | Downloads |
|---|---|
|
Zonit.Extensions.Website
ASP.NET Core and Blazor web extensions providing base components (PageBase, PageEditBase, PageViewBase), navigation services, breadcrumbs management, toast notifications, cookie handling, and data protection utilities for building modern web applications. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.0.0-preview.9 | 48 | 5/16/2026 |
| 10.0.0-preview.6 | 47 | 5/15/2026 |
| 10.0.0-preview.2 | 67 | 5/12/2026 |