![]() |
VOOZH | about |
dotnet add package RCommon.Web --version 2.4.1
NuGet\Install-Package RCommon.Web -Version 2.4.1
<PackageReference Include="RCommon.Web" Version="2.4.1" />
<PackageVersion Include="RCommon.Web" Version="2.4.1" />Directory.Packages.props
<PackageReference Include="RCommon.Web" />Project file
paket add RCommon.Web --version 2.4.1
#r "nuget: RCommon.Web, 2.4.1"
#:package RCommon.Web@2.4.1
#addin nuget:?package=RCommon.Web&version=2.4.1Install as a Cake Addin
#tool nuget:?package=RCommon.Web&version=2.4.1Install as a Cake Tool
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.
HttpContextCurrentPrincipalAccessor reads the authenticated user from IHttpContextAccessor.HttpContext.UserWithClaimsAndPrincipalAccessorForWeb() registers all security services wired to the HTTP contextWithClaimsAndPrincipalAccessor() in ASP.NET Core applicationsdotnet add package RCommon.Web
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.
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 ICurrentPrincipalAccessorIHttpContextAccessor (via AddHttpContextAccessor())ICurrentUser, ICurrentClient, ITenantIdAccessor (same as the non-web variant)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
});
}
}
| Type | Description |
|---|---|
HttpContextCurrentPrincipalAccessor |
ICurrentPrincipalAccessor implementation that reads from HttpContext.User |
WebConfigurationExtensions |
Provides WithClaimsAndPrincipalAccessorForWeb() extension method for DI registration |
For full documentation, visit rcommon.com.
ICurrentUser, ICurrentPrincipalAccessor, ITenantIdAccessor)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. |
This package is not used by any NuGet packages.
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 |