RCommon.Web 2.3.2-alpha.0.3

This is a prerelease version of RCommon.Web.
There is a newer version of this package available.
See the version list below for details.
dotnet add package RCommon.Web --version 2.3.2-alpha.0.3
                    
NuGet\Install-Package RCommon.Web -Version 2.3.2-alpha.0.3
                    
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="RCommon.Web" Version="2.3.2-alpha.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RCommon.Web" Version="2.3.2-alpha.0.3" />
                    
Directory.Packages.props
<PackageReference Include="RCommon.Web" />
                    
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 RCommon.Web --version 2.3.2-alpha.0.3
                    
#r "nuget: RCommon.Web, 2.3.2-alpha.0.3"
                    
#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 RCommon.Web@2.3.2-alpha.0.3
                    
#: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=RCommon.Web&version=2.3.2-alpha.0.3&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=RCommon.Web&version=2.3.2-alpha.0.3&prerelease
                    
Install as a Cake Tool

RCommon.Web

ASP.NET Core integration for the RCommon security abstractions. Provides HttpContextCurrentPrincipalAccessor which resolves the current ClaimsPrincipal from HttpContext.User instead of Thread.CurrentPrincipal, making ICurrentUser, ICurrentClient, ITenantIdAccessor, and all claims-based security abstractions work correctly in web applications.

Features

  • HTTP context principal accessor -- HttpContextCurrentPrincipalAccessor reads the authenticated user from IHttpContextAccessor.HttpContext.User
  • One-line DI registration -- WithClaimsAndPrincipalAccessorForWeb() registers all security services wired to the HTTP context
  • Drop-in replacement -- use instead of WithClaimsAndPrincipalAccessor() in ASP.NET Core applications
  • Targets .NET 8, .NET 9, and .NET 10

Installation

dotnet add package RCommon.Web

Usage

Why This Package?

The default ThreadCurrentPrincipalAccessor (from RCommon.Security) reads from Thread.CurrentPrincipal, which is null in ASP.NET Core. This means ICurrentUser, ClaimsTenantIdAccessor, and all claims-based services silently return null in web apps.

HttpContextCurrentPrincipalAccessor bridges this gap by reading from HttpContext.User.

Registration

Replace WithClaimsAndPrincipalAccessor() with WithClaimsAndPrincipalAccessorForWeb() in your ASP.NET Core application:

using RCommon;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRCommon(config =>
{
    // Use this instead of config.WithClaimsAndPrincipalAccessor()
    config.WithClaimsAndPrincipalAccessorForWeb();
});

This registers:

  • HttpContextCurrentPrincipalAccessor as ICurrentPrincipalAccessor
  • IHttpContextAccessor (via AddHttpContextAccessor())
  • ICurrentUser, ICurrentClient, ITenantIdAccessor (same as the non-web variant)

Using Security Services

Once registered, inject ICurrentUser, ICurrentClient, or ITenantIdAccessor in your controllers or services:

using RCommon.Security.Users;
using RCommon.Security.Claims;

public class OrderController : ControllerBase
{
    private readonly ICurrentUser _currentUser;
    private readonly ITenantIdAccessor _tenantIdAccessor;

    public OrderController(ICurrentUser currentUser, ITenantIdAccessor tenantIdAccessor)
    {
        _currentUser = currentUser;
        _tenantIdAccessor = tenantIdAccessor;
    }

    [HttpGet]
    public IActionResult GetUserInfo()
    {
        return Ok(new
        {
            UserId = _currentUser.UserId,
            TenantId = _tenantIdAccessor.GetTenantId(),
            Roles = _currentUser.Roles,
            IsAuthenticated = _currentUser.IsAuthenticated
        });
    }
}

Key Types

Type Description
HttpContextCurrentPrincipalAccessor ICurrentPrincipalAccessor implementation that reads from HttpContext.User
WebConfigurationExtensions Provides WithClaimsAndPrincipalAccessorForWeb() extension method for DI registration

Documentation

For full documentation, visit rcommon.com.

License

Licensed under the Apache License, Version 2.0.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 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.

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
2.4.1 27 2/18/2026
2.3.2-alpha.0.3 30 2/18/2026
2.3.2-alpha.0.2 26 2/18/2026
2.3.2-alpha.0.1 42 2/9/2026
2.3.1 91 2/5/2026
2.3.0 84 2/3/2026
2.2.2-alpha.0.1 388 12/11/2025
2.2.1-alpha.0.2 132 10/24/2025
2.2.1-alpha.0.1 124 10/24/2025
2.1.11-alpha.0.2 122 10/24/2025
2.1.11-alpha.0.1 96 7/18/2025
2.1.10 247 7/17/2025
2.1.9-alpha.0.1 139 7/17/2025
2.1.2.4 281 5/21/2025
2.1.2.3 279 5/1/2025
2.1.2.2 492 1/23/2025
2.1.2.1 225 1/17/2025
2.1.2 235 1/17/2025
2.1.1.4 229 1/7/2025
0.0.0-alpha.0 140 7/17/2025
Loading failed