Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Finbuckle/Finbuckle.MultiTenant
Finbuckle.MultiTenant is an open-source multitenancy middleware library for .NET. It enables tenant resolution, per-tenant app behavior, and per-tenant data isolation.
https://github.com/Finbuckle/Finbuckle.MultiTenant
aspnetcore aspnetcore-identity dotnet dotnetcore efcore entity-framework-core finbuckle middleware multitenant
Last synced: 9 days ago
JSON representation
Finbuckle.MultiTenant is an open-source multitenancy middleware library for .NET. It enables tenant resolution, per-tenant app behavior, and per-tenant data isolation.
- Host: GitHub
- URL: https://github.com/Finbuckle/Finbuckle.MultiTenant
- Owner: Finbuckle
- License: apache-2.0
- Created: 2017-09-01T13:33:35.000Z (about 7 years ago)
- Default Branch: main
- Last Pushed: 2024-10-17T17:51:34.000Z (18 days ago)
- Last Synced: 2024-10-20T02:34:13.944Z (16 days ago)
- Topics: aspnetcore, aspnetcore-identity, dotnet, dotnetcore, efcore, entity-framework-core, finbuckle, middleware, multitenant
- Language: C#
- Homepage: https://www.finbuckle.com/multitenant
- Size: 2.64 MB
- Stars: 1,321
- Watchers: 43
- Forks: 267
- Open Issues: 102
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-dotnet-core - Finbuckle.MultiTenant - Finbuckle.MultiTenant is a .NET Standard library for multitenant support designed for ASP.NET 2.0+. It provides functionality for tenant resolution, per-tenant app configuration, and per-tenant data isolation. (Frameworks, Libraries and Tools / Application Frameworks)
- fucking-awesome-dotnet-core - Finbuckle.MultiTenant - Finbuckle.MultiTenant is a .NET Standard library for multitenant support designed for ASP.NET 2.0+. It provides functionality for tenant resolution, per-tenant app configuration, and per-tenant data isolation. (Frameworks, Libraries and Tools / Application Frameworks)
- awesome-dotnet-core - Finbuckle.MultiTenant - Finbuckle.MultiTenant is a .NET Standard library for multitenant support designed for ASP.NET 2.0+. It provides functionality for tenant resolution, per-tenant app configuration, and per-tenant data isolation. (Frameworks, Libraries and Tools / Application Frameworks)
- awesome-dotnet-core - Finbuckle.MultiTenant - Finbuckle.MultiTenant是ASP.NET Core的多租户库。它提供用于租户解析,每个租户应用程序配置和每个租户数据隔离的功能。 (框架, 库和工具 / 应用程序框架)
README
# ![Finbuckle Logo](https://www.finbuckle.com/images/finbuckle-32x32-gh.png) Finbuckle.MultiTenant 7.0.1
## About Finbuckle.MultiTenant
Finbuckle.MultiTenant is an open-source multitenancy middleware library for .NET. It enables tenant resolution,
per-tenant app behavior, and per-tenant data isolation.
See [https://www.finbuckle.com/multitenant](https://www.finbuckle.com/multitenant) for more details and documentation.Current publish feed release:
![Finbuckle.MultiTenant NuGet.org badge](https://buildstats.info/nuget/finbuckle.multitenant)Table of Contents
1. [What's New in v7.0.1](#whats-new)
2. [Quick Start](#quick-start)
3. [Documentation](#documentation)
4. [Sample Projects](#sample-projects)
5. [Build and Test Status](#build-and-test-status)
6. [License](#license)
7. [.NET Foundation](#net-foundation)
8. [Code of Conduct](#code-of-conduct)
9. [Community](#community)
10. [Building from Source](#building-from-source)
11. [Running Unit Tests](#running-unit-tests)> This section only lists release update details specific to v7.0.1. See
> the [changelog file](CHANGELOG.md) for all release update details.### Bug Fixes
* only throw exception in EnforceMultiTenant for null tenant if there are entity changes. ([#819](https://github.com/Finbuckle/Finbuckle.MultiTenant/issues/819)) ([ca9e9fd](https://github.com/Finbuckle/Finbuckle.MultiTenant/commit/ca9e9fd9a55789d790d31f82756e5ecdac03a28f))
## Quick Start
Finbuckle.MultiTenant is designed to be easy to use and follows standard .NET conventions as much as possible. This
introduction assumes a standard ASP.NET Core use case, but any application using .NET dependency injection can work with
the library.### Installation
First, install the Finbuckle.MultiTenant.AspNetCore NuGet package:
.NET Core CLI
```bash
$ dotnet add package Finbuckle.MultiTenant.AspNetCore
```### Basic Configuration
Next, in the app's service configuration call `AddMultiTenant` and its various builder methods and in the
middleware configuration call `UseMultiTenant()`:```cs
builder.Services.AddMultiTenant()
.WithHostStrategy()
.WithConfigurationStore();// other app code...
app.UseMultiTenant();
// other app code...
app.Run();
```That's all that is needed to get going. Let's breakdown each line:
`builder.Services.AddMultiTenant()`
This line registers the base services and designates `TenantInfo` as the class that will hold tenant information at
runtime.The type parameter for `AddMultiTenant` must be an implementation of `ITenantInfo` which holds basic
information about the tenant such as its name and an identifier. `TenantInfo` is provided as a basic implementation, but
a custom implementation can be used if more properties are needed.See [Core Concepts](https://www.finbuckle.com/MultiTenant/Docs/CoreConcepts) for more information on `ITenantInfo`.
`.WithHostStrategy()`
The line tells the app that our "strategy" to determine the request tenant will be to look at the request host, which
defaults to the extracting the subdomain as a tenant identifier.See [MultiTenant Strategies](https://www.finbuckle.com/MultiTenant/Docs/Strategies) for more information.
`.WithConfigurationStore()`
This line tells the app that information for all tenants are in the `appsettings.json` file used for app configuration.
If a tenant in the store has the identifier found by the strategy, the tenant will be successfully resolved for the
current request.See [MultiTenant Stores](https://www.finbuckle.com/MultiTenant/Docs/Stores) for more information.
Finbuckle.MultiTenant comes with a collection of strategies and store types that can be mixed and matched in various
ways.`app.UseMultiTenant()`
This line configures the middleware which resolves the tenant using the registered strategies, stores, and other
settings. Be sure to call it before other middleware which will use per-tenant functionality,
e.g. `UseAuthentication()`.### Basic Usage
With the services and middleware configured, access information for the current tenant from the `TenantInfo` property on
the `MultiTenantContext` object accessed from the `GetMultiTenantContext` extension method:```cs
var tenantInfo = HttpContext.GetMultiTenantContext().TenantInfo;if(tenantInfo != null)
{
var tenantId = tenantInfo.Id;
var identifier = tenantInfo.Identifier;
var name = tenantInfo.Name;
}
```The type of the `TenantInfo` property depends on the type passed when calling `AddMultiTenant` during configuration.
If the current tenant could not be determined then `TenantInfo` will be null.The `ITenantInfo` instance and/or the typed instance are also available directly through dependency injection.
See [Configuration and Usage](https://www.finbuckle.com/MultiTenant/Docs/ConfigurationAndUsage) for more information.
## Documentation
The library builds on this basic functionality to provide a variety of higher level features. See
the [documentation](https://www.finbuckle.com/multitenant/docs) for
more details:* [Per-tenant Options](https://www.finbuckle.com/MultiTenant/Docs/Options)
* [Per-tenant Authentication](https://www.finbuckle.com/MultiTenant/Docs/Authentication)
* [Entity Framework Core Data Isolation](https://www.finbuckle.com/MultiTenant/Docs/EFCore)
* [ASP.NET Core Identity Data Isolation](https://www.finbuckle.com/MultiTenant/Docs/Identity)## Sample Projects
A variety of [sample projects](https://github.com/Finbuckle/Finbuckle.MultiTenant/tree/main/samples) are available in
the repository. Check older tagged release commits for samples from prior .NET versions.## Build and Test Status
![Build and Test Status](https://github.com/Finbuckle/Finbuckle.MultiTenant/actions/workflows/ci.yml/badge.svg)
## License
This project uses the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0). See [LICENSE](LICENSE) file for
license information.## .NET Foundation
This project is supported by the [.NET Foundation](https://dotnetfoundation.org).
## Code of Conduct
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our
community. For more information see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct)
or the [CONTRIBUTING.md](CONTRIBUTING.md) file.## Community
Check out the [GitHub repository](https://github.com/Finbuckle/Finbuckle.MultiTenant) to ask a question, make a request,
or peruse the code!## Building from Source
From the command line clone the git repository, `cd` into the new directory, and compile with `dotnet build`.
```bash
$ git clone https://github.com/Finbuckle/Finbuckle.MultiTenant.git
$ cd Finbuckle.MultiTenant
Cloning into 'Finbuckle.MultiTenant'...$ cd Finbuckle.MultiTenant
$ dotnet build
```## Running Unit Tests
Run the unit tests from the command line with `dotnet test` from the solution directory.
```bash
$ dotnet test
```