B2aTech.CrossCuttingConcern
1.8.6
dotnet add package B2aTech.CrossCuttingConcern --version 1.8.6
NuGet\Install-Package B2aTech.CrossCuttingConcern -Version 1.8.6
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="B2aTech.CrossCuttingConcern" Version="1.8.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="B2aTech.CrossCuttingConcern" Version="1.8.6" />
<PackageReference Include="B2aTech.CrossCuttingConcern" />
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 B2aTech.CrossCuttingConcern --version 1.8.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: B2aTech.CrossCuttingConcern, 1.8.6"
#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 B2aTech.CrossCuttingConcern@1.8.6
#: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=B2aTech.CrossCuttingConcern&version=1.8.6
#tool nuget:?package=B2aTech.CrossCuttingConcern&version=1.8.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
B2aTech.CrossCuttingConcern
A lightweight modular library for adding permission-based authorization, user context extensions, and configurable permission caching into ASP.NET Core projects.
Designed for .NET 9+ applications with clean dependency injection and easy configuration.
✨ Features
- Dynamic Permission Authorization Handler
- Attribute-based permission checks using
[RequiresPermissions]. - Supports organization and user-specific permissions.
- Attribute-based permission checks using
- PermissionService
- Caches permissions with sliding expiration.
- Supports parent-child permission hierarchy lookup.
- Configurable detailed logging (for debugging scenarios).
- HttpContext Extensions
GetDhanManUserId()utility to extract user ID from claims.
- Configurable Logging
- Control verbose logging via
EnableLoggingflag fromappsettings.json.
- Control verbose logging via
- Designed for NuGet
- Clean separation for easy plug-and-play.
🚀 Installation
Install via NuGet (once published):
dotnet add package B2aTech.CrossCuttingConcern
Or reference it manually via your .csproj:
<PackageReference Include="B2aTech.CrossCuttingConcern" Version="x.y.z" />
⚙️ Setup Instructions
In your Program.cs or Startup.cs, register services:
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpContextAccessor();
services.AddMemoryCache();
services.Configure<PermissionServiceOptions>(Configuration.GetSection("PermissionService"));
services.AddScoped<IPermissionService, PermissionService>();
services.AddScoped<IAuthorizationHandler, DynamicPermissionHandler>();
services.AddAuthorization(options =>
{
options.AddPolicy("DynamicPermissionPolicy", policy =>
{
policy.Requirements.Add(new PermissionRequirement());
});
});
}
📄 appsettings.json Configuration Example
{
"PermissionService": {
"EnableLogging": true
}
}
EnableLogging:true: Detailed logs during permission checks.false: Suppress logging output.
🧩 Usage Example
- Decorate your API endpoints with required permissions:
[Authorize(Policy = "DynamicPermissionPolicy")]
[RequiresPermissions("Dhanman.Community.Facility.Create", "Dhanman.Community.Facility.Read")]
[HttpGet("api/facilities")]
public IActionResult GetFacilities()
{
// Only users with the required permissions can access this endpoint
...
}
- The library will automatically:
- Extract
x-organization-idfrom request headers. - Extract
dhanmanIdfrom user claims. - Check against cached permissions.
- Allow or deny based on configuration.
- Extract
📦 Requirements
- .NET 9.0 or higher
- ASP.NET Core application (using Endpoint Routing)
- Must reference
Microsoft.AspNetCore.Appvia FrameworkReference (default for Web Apps)
🛡 License
Licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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.
-
net9.0
- MassTransit (>= 8.5.4)
- MassTransit.Extensions.DependencyInjection (>= 7.3.1)
- MassTransit.RabbitMQ (>= 8.5.4)
- Microsoft.AspNetCore.Authorization (>= 9.0.9)
- Microsoft.EntityFrameworkCore (>= 9.0.9)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.9)
- Microsoft.Extensions.Configuration (>= 9.0.9)
- Microsoft.Extensions.Configuration.FileExtensions (>= 9.0.9)
- Microsoft.Extensions.Configuration.Json (>= 9.0.9)
- Microsoft.Extensions.DependencyInjection (>= 9.0.9)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.9)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.9)
- Newtonsoft.Json (>= 13.0.4)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 9.0.4)
- RabbitMQ.Client (>= 7.1.2)
- Serilog (>= 4.3.0)
- Serilog.Enrichers.Context (>= 4.6.5)
- Serilog.Enrichers.Environment (>= 3.0.1)
- System.IdentityModel.Tokens.Jwt (>= 8.3.0)
- VaultSharp (>= 1.17.5.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on B2aTech.CrossCuttingConcern:
| Package | Downloads |
|---|---|
|
Dhanman.Shared.Contracts
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.8.6 | 167 | 2/3/2026 |
| 1.8.5 | 96 | 2/3/2026 |
| 1.8.4 | 407 | 1/15/2026 |
| 1.8.3 | 99 | 1/15/2026 |
| 1.8.2 | 106 | 1/15/2026 |
| 1.8.1 | 134 | 1/6/2026 |
| 1.8.0 | 1,008 | 11/2/2025 |
| 1.7.9 | 172 | 11/1/2025 |
| 1.7.8 | 373 | 10/14/2025 |
| 1.7.7 | 212 | 10/14/2025 |
| 1.7.6 | 197 | 10/14/2025 |
| 1.7.5 | 208 | 10/14/2025 |
| 1.7.4 | 207 | 10/13/2025 |
| 1.7.3 | 216 | 10/13/2025 |
| 1.7.2 | 438 | 10/12/2025 |
| 1.7.1 | 150 | 10/12/2025 |
| 1.7.0 | 160 | 10/12/2025 |
| 1.6.9 | 483 | 10/11/2025 |
| 1.6.8 | 215 | 10/9/2025 |
| 1.6.7 | 223 | 10/9/2025 |
Loading failed