Cosmos.MultiTenancy.AspNetCore 1.0.0

dotnet add package Cosmos.MultiTenancy.AspNetCore --version 1.0.0
                    
NuGet\Install-Package Cosmos.MultiTenancy.AspNetCore -Version 1.0.0
                    
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="Cosmos.MultiTenancy.AspNetCore" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Cosmos.MultiTenancy.AspNetCore" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Cosmos.MultiTenancy.AspNetCore" />
                    
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 Cosmos.MultiTenancy.AspNetCore --version 1.0.0
                    
#r "nuget: Cosmos.MultiTenancy.AspNetCore, 1.0.0"
                    
#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 Cosmos.MultiTenancy.AspNetCore@1.0.0
                    
#: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=Cosmos.MultiTenancy.AspNetCore&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Cosmos.MultiTenancy.AspNetCore&version=1.0.0
                    
Install as a Cake Tool

Cosmos.MultiTenancy.AspNetCore

Implementacion de ITenantResolver basada en los headers HTTP confiables X-Tenant-Id y X-User-Id para servicios ASP.NET Core en el ecosistema Cosmos.

Descripcion

En arquitecturas multi-tenant con gateway, el gateway agrega headers confiables (trusted headers) que identifican al tenant y al usuario. Este paquete provee TrustedHeadersTenantResolver, que lee el TenantId desde el header X-Tenant-Id y el UserId desde el header X-User-Id del HttpContext, y falla ruidosamente si el header correspondiente no esta presente, garantizando que los errores de gateway no pasen desapercibidos.

Instalacion

dotnet add package Cosmos.MultiTenancy.AspNetCore

Uso

AgregarTenantResolverConHeadersConfiables registra TrustedHeadersTenantResolver como ITenantResolver y agrega IHttpContextAccessor.

var builder = WebApplication.CreateBuilder(args);

builder.Services.AgregarWolverineCommandRouter();
builder.Services.AgregarTenantResolverConHeadersConfiables();

Comportamiento ante errores

TrustedHeadersTenantResolver.TenantId y .UserId lanzan InvalidOperationException en los siguientes casos:

Propiedad Condicion Mensaje de error
TenantId No hay HttpContext disponible "No hay HttpContext disponible para resolver el TenantId."
TenantId Header ausente o vacio "El header confiable 'X-Tenant-Id' no está presente o está vacío."
UserId No hay HttpContext disponible "No hay HttpContext disponible para resolver el UserId."
UserId Header ausente o vacio "El header confiable 'X-User-Id' no está presente o está vacío."

Este comportamiento es intencional: los headers son confiables y provienen del gateway. Si no estan presentes, es una falla del gateway que debe ser ruidosa.

Dependencias

  • Cosmos.MultiTenancy — provee ITenantResolver
  • Microsoft.AspNetCore.App (framework reference) — provee IHttpContextAccessor

Paquetes relacionados

Requisitos

  • .NET 10.0 o superior
  • Solo compatible con aplicaciones ASP.NET Core (requiere Microsoft.AspNetCore.App)

Licencia

Copyright © Cosmos. Todos los derechos reservados.

Product Compatible and additional computed target framework versions.
.NET 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 (1)

Showing the top 1 NuGet packages that depend on Cosmos.MultiTenancy.AspNetCore:

Package Downloads
Cosmos.MultiTenancy.CritterStack

Resolver de tenant compuesto para apps con HTTP y daemon de Wolverine (inbox/outbox). Lee del header HTTP cuando hay HttpContext y cae a IMessageContext.TenantId en handlers ejecutados por el daemon.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 0 6/2/2026
0.3.0 122 5/28/2026
0.2.0 475 5/22/2026
0.1.1 148 5/20/2026
0.1.0 91 5/20/2026