Athenex.Whimclean.Multitenancy.Abstractions
2.0.0
Prefix Reserved
dotnet add package Athenex.Whimclean.Multitenancy.Abstractions --version 2.0.0
NuGet\Install-Package Athenex.Whimclean.Multitenancy.Abstractions -Version 2.0.0
<PackageReference Include="Athenex.Whimclean.Multitenancy.Abstractions" Version="2.0.0" />
<PackageVersion Include="Athenex.Whimclean.Multitenancy.Abstractions" Version="2.0.0" />
<PackageReference Include="Athenex.Whimclean.Multitenancy.Abstractions" />
paket add Athenex.Whimclean.Multitenancy.Abstractions --version 2.0.0
#r "nuget: Athenex.Whimclean.Multitenancy.Abstractions, 2.0.0"
#:package Athenex.Whimclean.Multitenancy.Abstractions@2.0.0
#addin nuget:?package=Athenex.Whimclean.Multitenancy.Abstractions&version=2.0.0
#tool nuget:?package=Athenex.Whimclean.Multitenancy.Abstractions&version=2.0.0
Athenex.Whimclean.Multitenancy.Abstractions
Dependency-free contracts for optional multitenancy. The consuming application owns tenant management; this package defines only integration boundaries. All types live in the Athenex.Whimclean.Multitenancy namespace.
Install
dotnet add package Athenex.Whimclean.Multitenancy.Abstractions
Most applications install an EF or ASP.NET Core multitenancy adapter instead and receive this package transitively.
Mark tenant-owned entities
using Athenex.Whimclean.Multitenancy;
public sealed class Order : IMultiTenant<Guid>
{
public Guid Id { get; init; }
public Guid TenantId { get; init; }
}
IMultiTenant<TTenantId> indicates data ownership through a read-only TenantId. The optional EF adapter uses it for query filtering and write validation.
Requested tenant versus current tenant
IRequestedTenant<TTenantId>represents an untrusted tenant selected by a header, route, host, or similar request input.ICurrentTenant<TTenantId>represents the tenant established only after authorization.
Both expose TryGetTenantId(out TTenantId tenantId), which returns false when no tenant is present. Keeping these contracts separate prevents request input from automatically becoming an authorized data boundary.
AmbientCurrentTenant<TTenantId> is an ICurrentTenant<TTenantId> backed by an async-local scope for hosts without HTTP tenant resolution, such as background workers or seeders: wrap tenant-scoped work in using (AmbientCurrentTenant<Guid>.Begin(tenantId)). Scopes nest, disposing restores the previous tenant, and the caller vouches for the tenant because no access validation happens there.
Consumer-owned access validation
Implement ITenantAccessValidator<TUserId, TTenantId> against the application’s own membership storage and rules:
public sealed class TenantMembershipAccessValidator(
AuthenticationDbContext dbContext)
: ITenantAccessValidator<Guid, Guid>
{
public Task<bool> HasAccessAsync(
Guid userId,
Guid tenantId,
CancellationToken cancellationToken = default) =>
dbContext.TenantMemberships.AnyAsync(
membership =>
membership.UserId == userId &&
membership.TenantId == tenantId &&
membership.IsActive,
cancellationToken);
}
Implementations should fail closed and return false for unknown users or tenants. The consumer owns:
TenantandTenantMembershipentities- tenant creation, suspension, and deletion
- membership invitation, roles, state, and expiry
- subscription or entitlement rules
- administrative cross-tenant authorization
The package also defines CurrentTenantRequiredException (tenant-owned changes are about to be persisted without an established current tenant) and TenantAccessViolationException (a save would change a record owned by another tenant) for fail-closed persistence boundaries.
This package has no Domain, Application, EF Core, ASP.NET Core, Identity, or database-provider dependency.
Repository and full architecture guide: https://github.com/athene-x/Whimclean
| Product | Versions 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. |
-
net10.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Athenex.Whimclean.Multitenancy.Abstractions:
| Package | Downloads |
|---|---|
|
Athenex.Whimclean.Infrastructure.EntityFrameworkCore.Multitenancy
Optional provider-neutral EF Core multitenancy enforcement with fail-closed query filters and write validation. |
|
|
Athenex.Whimclean.Api.AspNetCore.Multitenancy
Framework-neutral ASP.NET Core multitenancy integration with requested-tenant resolution, membership authorization, authorized tenant context, and API error mapping; works with FastEndpoints or Minimal APIs. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 112 | 11/17/2026 |
2.0.0: first nuget.org release. Dependency-free requested and current tenant, tenant ownership, access validation and boundary exception contracts.