RCommon.Web
2.3.2-alpha.0.3
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
<PackageReference Include="RCommon.Web" Version="2.3.2-alpha.0.3" />
<PackageVersion Include="RCommon.Web" Version="2.3.2-alpha.0.3" />
<PackageReference Include="RCommon.Web" />
paket add RCommon.Web --version 2.3.2-alpha.0.3
#r "nuget: RCommon.Web, 2.3.2-alpha.0.3"
#:package RCommon.Web@2.3.2-alpha.0.3
#addin nuget:?package=RCommon.Web&version=2.3.2-alpha.0.3&prerelease
#tool nuget:?package=RCommon.Web&version=2.3.2-alpha.0.3&prerelease
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 --
HttpContextCurrentPrincipalAccessorreads the authenticated user fromIHttpContextAccessor.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:
HttpContextCurrentPrincipalAccessorasICurrentPrincipalAccessorIHttpContextAccessor(viaAddHttpContextAccessor())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
- RCommon.Security - Core security abstractions (
ICurrentUser,ICurrentPrincipalAccessor,ITenantIdAccessor) - RCommon.Authorization.Web - Swagger/OpenAPI authorization filters for ASP.NET Core
- RCommon.Core - Core abstractions and builder infrastructure
License
Licensed under the Apache License, Version 2.0.
| Product | Versions 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. |
-
net10.0
- RCommon.Security (>= 2.3.2-alpha.0.3)
-
net8.0
- RCommon.Security (>= 2.3.2-alpha.0.3)
-
net9.0
- RCommon.Security (>= 2.3.2-alpha.0.3)
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 |