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" />
                    
Directory.Packages.props
<PackageReference Include="B2aTech.CrossCuttingConcern" />
                    
Project file
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
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=B2aTech.CrossCuttingConcern&version=1.8.6
                    
Install as a Cake Tool

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.
  • 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 EnableLogging flag from appsettings.json.
  • 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

  1. 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
    ...
}
  1. The library will automatically:
    • Extract x-organization-id from request headers.
    • Extract dhanmanId from user claims.
    • Check against cached permissions.
    • Allow or deny based on configuration.

📦 Requirements

  • .NET 9.0 or higher
  • ASP.NET Core application (using Endpoint Routing)
  • Must reference Microsoft.AspNetCore.App via FrameworkReference (default for Web Apps)

🛡 License

Licensed under the MIT License.

Product 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.

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