B2aTech.CrossCuttingConcern
2.0.0
dotnet add package B2aTech.CrossCuttingConcern --version 2.0.0
NuGet\Install-Package B2aTech.CrossCuttingConcern -Version 2.0.0
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="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="B2aTech.CrossCuttingConcern" Version="2.0.0" />
<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 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: B2aTech.CrossCuttingConcern, 2.0.0"
#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@2.0.0
#: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=2.0.0
#tool nuget:?package=B2aTech.CrossCuttingConcern&version=2.0.0
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 | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- MassTransit (>= 8.5.4)
- MassTransit.Extensions.DependencyInjection (>= 7.3.1)
- MassTransit.RabbitMQ (>= 8.5.4)
- Microsoft.EntityFrameworkCore (>= 10.0.13)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.13)
- Newtonsoft.Json (>= 13.0.4)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 10.0.3)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.20.1)
- OpenTelemetry.Extensions.Hosting (>= 1.20.1)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.20.1)
- OpenTelemetry.Instrumentation.Http (>= 1.20.1)
- RabbitMQ.Client (>= 7.2.2)
- Serilog (>= 4.4.0)
- Serilog.Enrichers.Context (>= 4.6.5)
- Serilog.Enrichers.Environment (>= 3.0.1)
- System.IdentityModel.Tokens.Jwt (>= 8.23.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 |
|---|---|---|
| 2.0.0 | 83 | 10/21/2026 |
| 1.9.1 | 74 | 10/21/2026 |
| 1.9.0 | 104 | 10/20/2026 |
| 1.8.7 | 1,856 | 4/30/2026 |
| 1.8.6 | 315 | 2/3/2026 |
| 1.8.5 | 162 | 2/3/2026 |
| 1.8.4 | 1,015 | 1/15/2026 |
| 1.8.3 | 161 | 1/15/2026 |
| 1.8.2 | 167 | 1/15/2026 |
| 1.8.1 | 194 | 1/6/2026 |
| 1.8.0 | 2,156 | 11/2/2025 |
| 1.7.9 | 233 | 11/1/2025 |
| 1.7.8 | 429 | 10/14/2025 |
| 1.7.7 | 274 | 10/14/2025 |
| 1.7.6 | 253 | 10/14/2025 |
| 1.7.5 | 267 | 10/14/2025 |
| 1.7.4 | 258 | 10/13/2025 |
| 1.7.3 | 278 | 10/13/2025 |
| 1.7.2 | 1,010 | 10/12/2025 |
| 1.7.1 | 201 | 10/12/2025 |
Loading failed