B2aTech.CrossCuttingConcern 1.5.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package B2aTech.CrossCuttingConcern --version 1.5.1
                    
NuGet\Install-Package B2aTech.CrossCuttingConcern -Version 1.5.1
                    
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.5.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="B2aTech.CrossCuttingConcern" Version="1.5.1" />
                    
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.5.1
                    
#r "nuget: B2aTech.CrossCuttingConcern, 1.5.1"
                    
#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.5.1
                    
#: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.5.1
                    
Install as a Cake Addin
#tool nuget:?package=B2aTech.CrossCuttingConcern&version=1.5.1
                    
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.6.4 136 9/2/2025
1.6.3 584 8/1/2025
1.6.2 329 7/15/2025
1.6.1 653 7/1/2025
1.6.0 147 6/30/2025
1.5.9 168 6/28/2025
1.5.8 99 6/28/2025
1.5.7 67 6/28/2025
1.5.6 67 6/28/2025
1.5.5 72 6/28/2025
1.5.4 168 6/27/2025
1.5.3 131 6/27/2025
1.5.2 142 6/26/2025
1.5.1 138 6/26/2025
1.5.0 182 6/26/2025
1.4.9 214 6/18/2025
1.4.8 145 6/14/2025
1.4.7 151 6/14/2025
1.4.6 173 6/14/2025
1.4.5 156 6/14/2025
1.4.4 159 5/18/2025
1.4.3 316 5/16/2025
1.4.2 221 5/16/2025
1.4.1 233 5/15/2025
1.4.0 507 4/30/2025
1.3.9 162 4/29/2025
1.3.8 201 4/27/2025
1.3.7 138 4/27/2025
1.3.6 139 4/27/2025
1.3.5 146 4/27/2025
1.3.4 390 4/21/2025
1.3.3 397 4/15/2025
1.3.2 288 4/11/2025
1.3.1 423 3/28/2025
1.3.0 154 3/28/2025
1.2.9 153 3/28/2025
1.2.8 1,021 9/19/2024
1.2.7 645 9/19/2024
1.2.6 199 9/6/2024
1.2.5 155 8/31/2024
1.2.4 140 8/31/2024
1.2.3 147 8/31/2024
1.2.2 147 8/30/2024
1.2.1 211 8/15/2024
1.2.0 756 6/29/2024
1.1.9 170 6/29/2024
1.1.8 185 6/25/2024
1.1.7 134 6/25/2024
1.1.6 142 6/25/2024
1.1.5 143 6/25/2024
1.1.4 192 6/20/2024
1.1.3 303 5/20/2024
1.1.2 152 5/20/2024
1.1.1 153 5/20/2024
1.1.0 167 5/20/2024
1.0.9 692 3/23/2024
1.0.8 494 12/2/2023
1.0.7 162 12/2/2023
1.0.6 159 12/2/2023
1.0.5 2,234 8/22/2023