VOOZH about

URL: https://www.nuget.org/packages/RCommon.Web

⇱ NuGet Gallery | RCommon.Web 2.4.1




👁 Image
RCommon.Web 2.4.1

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package RCommon.Web --version 2.4.1
 
 
NuGet\Install-Package RCommon.Web -Version 2.4.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="RCommon.Web" Version="2.4.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RCommon.Web" Version="2.4.1" />
 
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.4.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RCommon.Web, 2.4.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 RCommon.Web@2.4.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=RCommon.Web&version=2.4.1
 
Install as a Cake Addin
#tool nuget:?package=RCommon.Web&version=2.4.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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.

Related Packages

License

Licensed under the Apache License, Version 2.0.

Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows 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
3.1.0-alpha.3 77 5/18/2026
2.4.2-alpha.0.10 122 4/5/2026
2.4.2-alpha.0.9 65 3/26/2026
2.4.2-alpha.0.8 66 3/26/2026
2.4.2-alpha.0.7 63 3/26/2026
2.4.2-alpha.0.6 68 3/25/2026
2.4.2-alpha.0.5 69 3/24/2026
2.4.2-alpha.0.1 65 3/24/2026
2.4.1 135 2/18/2026
2.3.2-alpha.0.3 75 2/18/2026
2.3.2-alpha.0.2 66 2/18/2026
2.3.2-alpha.0.1 75 2/9/2026
2.3.1 215 2/5/2026
2.3.0 127 2/3/2026
2.2.2-alpha.0.1 412 12/11/2025
2.2.1-alpha.0.2 155 10/24/2025
2.2.1-alpha.0.1 148 10/24/2025
2.1.11-alpha.0.2 150 10/24/2025
2.1.11-alpha.0.1 120 7/18/2025
2.1.10 285 7/17/2025
Loading failed