Pragmatic.Authorization
1.0.0-alpha.6
dotnet add package Pragmatic.Authorization --version 1.0.0-alpha.6
NuGet\Install-Package Pragmatic.Authorization -Version 1.0.0-alpha.6
<PackageReference Include="Pragmatic.Authorization" Version="1.0.0-alpha.6" />
<PackageVersion Include="Pragmatic.Authorization" Version="1.0.0-alpha.6" />
<PackageReference Include="Pragmatic.Authorization" />
paket add Pragmatic.Authorization --version 1.0.0-alpha.6
#r "nuget: Pragmatic.Authorization, 1.0.0-alpha.6"
#:package Pragmatic.Authorization@1.0.0-alpha.6
#addin nuget:?package=Pragmatic.Authorization&version=1.0.0-alpha.6&prerelease
#tool nuget:?package=Pragmatic.Authorization&version=1.0.0-alpha.6&prerelease
Pragmatic.Authorization
The authorization engine for Pragmatic.Design: permissions, roles, groups, wildcard matching, resource (instance-level) policies, and a permission cache, declarative and observable.
The Problem
Authorization in most .NET apps starts simple and rots. Permission strings are hardcoded and scattered
across controllers; role-to-permission mapping lives in if-statements; wildcard handling is
hand-rolled and inconsistent; instance-level checks ("can this user act on this invoice?") are buried
in business logic. Ask "what can the booking-manager role do?" and the answer means reading every
controller.
// Typical: scattered, fragile, invisible
var permissions = User.Claims.Where(c => c.Type == "permission").Select(c => c.Value).ToHashSet();
if (!permissions.Contains("booking.reservation.cancel")
&& !permissions.Any(p => p == "booking.reservation.*")
&& !permissions.Contains("*"))
return Forbid();
The Solution
Declare what is protected and how; the framework handles resolution, wildcard matching, caching, and enforcement.
[DomainAction]
[RequirePermission(BookingPermissions.Reservation.Cancel)]
[RequirePolicy<ReservationCancellationPolicy>]
public sealed partial class CancelReservationAction : VoidDomainAction
{
// business logic only: no authorization code here
}
// Roles compose from module definitions, declared once in Program.cs
app.UseAuthorization(authz =>
{
authz.MapRole<BookingManagerRole>(r => r
.IncludeDefinition<BookingOperator>()
.IncludeDefinition<CatalogReader>());
authz.AddResourceAuthorizer<InvoiceAuthorizer>(); // instance-level (ABAC)
authz.UsePermissionCache(TimeSpan.FromMinutes(5));
});
What it covers
- Permissions: wildcard-aware matching (
booking.*,*), one generated{Boundary}Permissionsclass ofconsts: the entities' CRUD and the custom ones declared with[assembly: Permission]. - Roles & groups: compose roles from reusable definitions; map groups to roles.
- Resource policies (
ResourcePolicy): instance-level "can this user act on this object?" checks. - Stores & caching: pluggable role/permission/group stores; cross-request
HybridCache. - Pipeline enforcement:
[RequirePermission]/[RequirePolicy]enforced in the Actions/Endpoints pipeline.
Installation
dotnet add package Pragmatic.Authorization
dotnet add package Pragmatic.SourceGenerator # generates permission constants/registry
Status
Functional within 1.0.0-alpha: roles, groups, wildcard permissions, resource authorizers, and the permission cache. See the roadmap.
Documentation
| Guide | What you'll learn |
|---|---|
| Concepts | Mental model, permission strings, the resolution chain, where authorization runs |
| Getting Started | Protect an action, define permissions, map a role |
| Permission Resolution | The full resolution chain, wildcard matching, caching |
| Roles & Groups | IRole/IRoleDefinition, composition, groups |
| Policies | ResourcePolicy, [RequirePolicy<T>], instance-level (ABAC) checks |
| Stores | Role/permission/group stores, customization, temporal/tenant variants |
| Common Mistakes | The most frequent authorization pitfalls |
| Troubleshooting | Problem/solution guide with diagnostics |
Cross-module integration
Enforced by Actions and Endpoints;
identity comes from Identity; data-level filters live in
Persistence. Interfaces live in Pragmatic.Abstractions.
Requirements
- .NET 10.0+
Pragmatic.SourceGeneratoranalyzer
License
Part of the Pragmatic.Design ecosystem. See Licensing. Pragmatic.Authorization is licensed under the PolyForm Small Business 1.0.0 license (free for small businesses; commercial license above the threshold).
| 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. net11.0 is compatible. |
-
net10.0
- Microsoft.Extensions.Options (>= 10.0.10)
- Pragmatic.Abstractions (>= 1.0.0-alpha.6)
-
net11.0
- Pragmatic.Abstractions (>= 1.0.0-alpha.6)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Pragmatic.Authorization:
| Package | Downloads |
|---|---|
|
Pragmatic.Actions
DomainAction pattern with Pipeline, Filters, and Boundary support. Zero reflection, compile-time safe, source-generated. |
|
|
Pragmatic.Identity.Persistence
EF Core persistence for identity: temporal role, group and permission stores. |
|
|
Pragmatic.Authorization.Management
RBAC management package for Pragmatic.Design. Dynamic permissions, roles, groups, and user assignments, persisted by the engine of the boundary that imports it: with Pragmatic.Authorization.Management.EFCore on EF Core, with Pragmatic.Authorization.Management.Engines on the Sql and documents engines. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.6 | 302 | 11/21/2026 |
| 1.0.0-alpha.5 | 232 | 11/21/2026 |
| 1.0.0-alpha.4 | 294 | 11/16/2026 |
| 1.0.0-alpha.3 | 619 | 10/17/2026 |
| 1.0.0-alpha.2 | 235 | 10/12/2026 |
| 1.0.0-alpha.1 | 457 | 10/3/2026 |