RepletoryLib.Auth.Permissions
1.0.0
dotnet add package RepletoryLib.Auth.Permissions --version 1.0.0
NuGet\Install-Package RepletoryLib.Auth.Permissions -Version 1.0.0
<PackageReference Include="RepletoryLib.Auth.Permissions" Version="1.0.0" />
<PackageVersion Include="RepletoryLib.Auth.Permissions" Version="1.0.0" />
<PackageReference Include="RepletoryLib.Auth.Permissions" />
paket add RepletoryLib.Auth.Permissions --version 1.0.0
#r "nuget: RepletoryLib.Auth.Permissions, 1.0.0"
#:package RepletoryLib.Auth.Permissions@1.0.0
#addin nuget:?package=RepletoryLib.Auth.Permissions&version=1.0.0
#tool nuget:?package=RepletoryLib.Auth.Permissions&version=1.0.0
RepletoryLib.Auth.Permissions
Permission-based authorization with [RequirePermission] attribute and policy provider for ASP.NET Core.
Part of the RepletoryLib ecosystem -- standalone, reusable .NET 10 libraries with zero business logic.
Overview
RepletoryLib.Auth.Permissions adds declarative, permission-based authorization to ASP.NET Core. Instead of checking roles, you decorate controllers and actions with [RequirePermission("orders.read")] and the framework handles the rest through a custom IAuthorizationPolicyProvider and AuthorizationHandler.
Key Features
[RequirePermission]attribute -- Declarative permission checks on controllers/actions- Dynamic policy provider -- Auto-creates authorization policies from permission names
ICurrentUserServiceintegration -- Checks permissions viaHasPermission()- Fine-grained RBAC -- Permission-level control instead of coarse role checks
Installation
dotnet add package RepletoryLib.Auth.Permissions
Dependencies
| Package | Type |
|---|---|
RepletoryLib.Common |
RepletoryLib |
Quick Start
using RepletoryLib.Auth.Permissions;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRepletoryPermissions();
Usage Examples
Decorating Controllers
using RepletoryLib.Auth.Permissions.Attributes;
[ApiController]
[Route("api/[controller]")]
public class OrdersController : ControllerBase
{
[HttpGet]
[RequirePermission("orders.read")]
public IActionResult GetOrders() => Ok(_orderService.GetAll());
[HttpPost]
[RequirePermission("orders.create")]
public IActionResult CreateOrder(CreateOrderRequest request) => Ok(_orderService.Create(request));
[HttpDelete("{id}")]
[RequirePermission("orders.delete")]
public IActionResult DeleteOrder(Guid id)
{
_orderService.Delete(id);
return NoContent();
}
}
How It Works
[RequirePermission("orders.read")]translates to policy name"Permission:orders.read"PermissionPolicyProvidercreates a policy with aPermissionAuthorizationRequirementPermissionAuthorizationHandlercallsICurrentUserService.HasPermission("orders.read")- If the user has the permission, access is granted; otherwise, 403 Forbidden
Implementing ICurrentUserService
Your ICurrentUserService implementation must return true from HasPermission() for the user's assigned permissions:
public class HttpCurrentUserService : ICurrentUserService
{
// ... other properties ...
public bool HasPermission(string permission)
{
return _httpContext?.User.HasClaim("permission", permission) ?? false;
}
}
Integration with Other RepletoryLib Packages
| Package | Relationship |
|---|---|
RepletoryLib.Common |
ICurrentUserService for permission checks |
RepletoryLib.Auth.Jwt |
JWT tokens carry permission claims; provides ICurrentUserService |
License
This project is licensed under the MIT License.
Copyright (c) 2024-2026 Repletory.
For complete documentation, infrastructure setup, and configuration reference, see the RepletoryLib main repository.
| 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
- RepletoryLib.Common (>= 1.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.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 140 | 3/2/2026 |