PrimusSaaS.MultiTenancy
1.1.0
dotnet add package PrimusSaaS.MultiTenancy --version 1.1.0
NuGet\Install-Package PrimusSaaS.MultiTenancy -Version 1.1.0
<PackageReference Include="PrimusSaaS.MultiTenancy" Version="1.1.0" />
<PackageVersion Include="PrimusSaaS.MultiTenancy" Version="1.1.0" />
<PackageReference Include="PrimusSaaS.MultiTenancy" />
paket add PrimusSaaS.MultiTenancy --version 1.1.0
#r "nuget: PrimusSaaS.MultiTenancy, 1.1.0"
#:package PrimusSaaS.MultiTenancy@1.1.0
#addin nuget:?package=PrimusSaaS.MultiTenancy&version=1.1.0
#tool nuget:?package=PrimusSaaS.MultiTenancy&version=1.1.0
PrimusSaaS.MultiTenancy
Release status: stable.
Core package for tenant context, resolution contracts, and multi-tenancy options.
The core runtime and package integrations are validated in the current workspace. Remaining work is ecosystem expansion and broader repo hygiene, not a current code-path release blocker.
Validation
- Current workspace validation:
242/242tests passed onnet8.0,net9.0, andnet10.0 - Current workspace validation: smoke tests
5/5passed onnet8.0,net9.0, andnet10.0 - Current workspace validation: coverage stayed above the configured threshold on all three frameworks (
95.45%line /87.22%branch onnet8.0;95.38%line /87.22%branch onnet9.0andnet10.0) - Scope boundary: core resolution/isolation/runtime only; tenant provisioning and platform workflows stay outside the core package
Telemetry
- Emits
ActivitySourcespans for tenant resolution, isolation, propagation, diagnostics, and feature-flag bridge flows. - Consumers still need to wire their own exporter if they want those spans collected outside the process.
- The package intentionally stays exporter-agnostic and does not force a telemetry backend.
For a verified new-app onboarding path that combines Identity Validator + Multi-Tenancy + RBAC in one ASP.NET Core host, use the Docusaurus guide at /docs/modules/combined-dotnet-integration.
Quick start
builder.Services.AddPrimusMultiTenancy(options =>
{
options.TenantClaimType = "tid";
options.TenantHeaderName = "X-Tenant-Id";
options.TenantRouteKey = "tenantId";
options.EnableSubdomainResolution = false;
options.RequireTenantOnAuthenticatedRequests = true;
options.EnableTenantRateLimiting = true;
options.RateLimitMaxRequests = 100;
options.RateLimitWindow = TimeSpan.FromMinutes(1);
});
Options reference
| Option | Type | Default | Description |
|---|---|---|---|
TenantClaimType |
string |
"tid" |
Primary JWT claim name read by ClaimsTenantResolutionStrategy |
TenantClaimTypes |
string[] |
["tid","tenant_id","tenantId","org_id"] |
Ordered tenant claim fallbacks checked by ClaimsTenantResolutionStrategy |
TenantHeaderName |
string |
"X-Tenant-Id" |
HTTP header name read by HeaderTenantResolutionStrategy |
TenantRouteKey |
string |
"tenantId" |
Route parameter name read by RouteTenantResolutionStrategy |
EnableSubdomainResolution |
bool |
false |
Activates SubdomainTenantResolutionStrategy (reads HTTP Host header) |
RequireTenantOnAuthenticatedRequests |
bool |
true |
Isolation middleware returns 401 when authenticated request has no tenant |
EnableTenantRateLimiting |
bool |
true |
Activates per-tenant rate limiting in TenantRateLimitMiddleware |
RateLimitMaxRequests |
int |
100 |
Maximum requests per tenant per window |
RateLimitWindow |
TimeSpan |
00:01:00 |
Rate-limit sliding window duration |
SuperAdminClaimType |
string |
"primus:role" |
Claim type checked for tenant bypass |
SuperAdminClaimValue |
string |
"superadmin" |
Claim value required to activate bypass |
PerTenantRateLimits |
Dictionary<string, TenantRateLimitPolicy> |
empty | Per-tenant override for max/window |
Default resolver precedence
- Claims (
TenantClaimType) - Header (
TenantHeaderName) - Route value (
TenantRouteKey) - Subdomain — opt-in via
EnableSubdomainResolution - Active membership via
ITenantMembershipStore
Related packages
PrimusSaaS.MultiTenancy.AspNetCore— middleware pipeline extensions (UsePrimusTenantResolution,UsePrimusTenantIsolation,UsePrimusTenantRateLimiting)PrimusSaaS.MultiTenancy.EFCore— write interceptor andModelBuilderschema enforcementPrimusSaaS.MultiTenancy.InMemory— in-memoryITenantMembershipStorefor development and tests
New extension points
TenantContextSnapshot— preferred unified snapshot API for capturing, transporting, and restoring tenant state across request and background execution scopes.ITenantRateLimiter— plug in a distributed limiter implementation (for example Redis-backed) to enforce tenant limits across instances.ITenantStorehelper extensions:SuspendTenantAsync(...),ActivateTenantAsync(...),SoftDeleteTenantAsync(...)ITenantMembershipStorehelper extension:GetAccessibleTenantsAsync(...)for tenant switcher scenariosAddPrimusMultiTenancyMembershipCaching(...)— wraps the registered membership store withIMemoryCache.ITenantDataRetentionService— contract for deleting all tenant-owned data during offboarding.ITenantFeatureFlagBridge— default bridge toPrimusSaaS.FeatureFlagsthat fail-closes when no flag service is registered.
| 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
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options (>= 8.0.2)
- PrimusSaaS.Rbac (>= 2.0.0)
-
net8.0
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options (>= 8.0.2)
- PrimusSaaS.Rbac (>= 2.0.0)
-
net9.0
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options (>= 8.0.2)
- PrimusSaaS.Rbac (>= 2.0.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on PrimusSaaS.MultiTenancy:
| Package | Downloads |
|---|---|
|
PrimusSaaS.MultiTenancy.InMemory
In-memory storage and resolver adapters for PrimusSaaS.MultiTenancy. |
|
|
PrimusSaaS.Memberships.InMemory
In-memory stores and bridge adapters for PrimusSaaS.Memberships development and test scenarios. |
|
|
PrimusSaaS.MultiTenancy.AspNetCore
ASP.NET Core middleware and helpers for PrimusSaaS.MultiTenancy. |
|
|
PrimusSaaS.Identity.Broker.Routing
Optional tenant-aware routing composition add-on for PrimusSaaS.Identity.Broker. Adds generic host-resolution abstractions and middleware without imposing app-specific domain, slug, or provider rules. |
|
|
PrimusSaaS.Memberships.EFCore
Entity Framework Core integration for PrimusSaaS.Memberships. |
GitHub repositories
This package is not used by any popular GitHub repositories.