Nedo.AspNet.Authentication.MultiTenant
2.0.9
dotnet add package Nedo.AspNet.Authentication.MultiTenant --version 2.0.9
NuGet\Install-Package Nedo.AspNet.Authentication.MultiTenant -Version 2.0.9
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="Nedo.AspNet.Authentication.MultiTenant" Version="2.0.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nedo.AspNet.Authentication.MultiTenant" Version="2.0.9" />
<PackageReference Include="Nedo.AspNet.Authentication.MultiTenant" />
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 Nedo.AspNet.Authentication.MultiTenant --version 2.0.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Nedo.AspNet.Authentication.MultiTenant, 2.0.9"
#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 Nedo.AspNet.Authentication.MultiTenant@2.0.9
#: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=Nedo.AspNet.Authentication.MultiTenant&version=2.0.9
#tool nuget:?package=Nedo.AspNet.Authentication.MultiTenant&version=2.0.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Nedo.AspNet.Authentication.MultiTenant
Tenant resolution + per-tenant authentication policy for the Nedo auth platform. Resolve the current tenant from a header / claim / subdomain / route, then key your downstream auth + storage decisions on it.
Install
dotnet add package Nedo.AspNet.Authentication.MultiTenant
Quickstart
using Nedo.AspNet.Authentication.MultiTenant;
builder.Services.AddNedoMultiTenant(opts =>
{
// Pick one or chain multiple — first match wins.
opts.ResolveFromHeader("X-Tenant-Id");
opts.ResolveFromClaim("tenant");
opts.ResolveFromSubdomain(); // acme.app.example.com → "acme"
opts.ResolveFromRoute("tenant"); // /api/{tenant}/orders → "acme"
});
var app = builder.Build();
app.UseAuthentication();
app.UseNedoAuthContext();
app.UseNedoMultiTenant(); // populates ITenantContext on the request
app.UseAuthorization();
Use it from your code
app.MapGet("/whoami", (IAuthContext auth, ITenantContext tenant)
=> new { auth.UserId, tenant = tenant.TenantId });
Resolution strategies
| Strategy | Source | Use when |
|---|---|---|
ResolveFromHeader(name) |
X-Tenant-Id: acme |
Backend-to-backend; trusted gateway sets the header. |
ResolveFromClaim(type) |
"tenant": "acme" claim on the JWT |
Tenant baked into the access token (most common for SPA / mobile). |
ResolveFromSubdomain() |
acme.app.example.com |
Per-tenant subdomain branding. |
ResolveFromRoute(name) |
/api/{tenant}/orders |
Path-based multi-tenancy for tools where subdomains are awkward. |
Chain multiple by calling them in order — the first non-null result wins.
Custom resolver
public class DatabaseTenantResolver : ITenantResolver
{
public Task<string?> ResolveAsync(HttpContext context, CancellationToken ct)
=> /* look up by host, by user, by anything */;
}
builder.Services.AddNedoMultiTenant(opts => opts.AddResolver<DatabaseTenantResolver>());
Docs
docs/07-multi-tenant.md — full guide including per-tenant JwtBearer schemes, EF Core tenant filters, and avoiding the "tenant from header on a public endpoint" footgun.
License
MIT — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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.
-
net9.0
- Nedo.AspNet.Authentication.Abstractions (>= 2.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.