Kephas.Tenants
11.0.0-dev.3
Prefix Reserved
See the version list below for details.
dotnet add package Kephas.Tenants --version 11.0.0-dev.3
NuGet\Install-Package Kephas.Tenants -Version 11.0.0-dev.3
<PackageReference Include="Kephas.Tenants" Version="11.0.0-dev.3" />
paket add Kephas.Tenants --version 11.0.0-dev.3
#r "nuget: Kephas.Tenants, 11.0.0-dev.3"
// Install Kephas.Tenants as a Cake Addin #addin nuget:?package=Kephas.Tenants&version=11.0.0-dev.3&prerelease // Install Kephas.Tenants as a Cake Tool #tool nuget:?package=Kephas.Tenants&version=11.0.0-dev.3&prerelease
Tenants
Introduction
This package adds support for multi-tenant applications.
How it works:
- Include the
Kephas.Tenants
package in the application deployment. - The application receives the tenant identifier through the
tenant
command line argument or theKEPHASAPP_Tenant
environment variable. - The tenant is available in code through
IAppArgs.Tenant()
extension method or theIContext.Tenant()
extension method.- Note that
IAppArgs
are available through dependency injection andIContext
instances through the parameter received in context dependent invocations.
- Note that
- When setting up the
IAmbientServices
during application bootstrapping, make sure to invoke theambientServices.WithTenantSupoport()
.- Do this typically before setting up the application runtime (for example
WithStaticAppRuntime
,WithDynamicAppRuntime
, orWithPluginsAppRuntime
), to make sure the runtime accesses the correct locations.
- Do this typically before setting up the application runtime (for example
What is the immediate effect:
- Tenant administrative mode
- When the application was started without a tenant identifier specified either in command line arguments or in the environment variables. This mode should allow tenant management actions.
- The folder locations are not changed.
- Tenant specific mode
- The tenant identifier is passed to the running application.
- The folder locations (config, licenses, plugins) are found in the
{tenant}
subdirectory of the original folder locations.
Example
public static IAmbientServices SetupAmbientServices(
this IAmbientServices ambientServices,
Func<IAmbientServices, IEncryptionService> encryptionServiceFactory,
IConfiguration? configuration,
IAppArgs appArgs)
{
return ambientServices
.WithDefaultLicensingManager(encryptionServiceFactory(ambientServices))
// Do not forget setting up the tenant support right *after* setting up the application runtime.
.WithTenantSupport(appArgs)
//
.WithDynamicAppRuntime()
.WithSerilogManager(configuration);
}
Security
Tenants management
A global scope tenantsmanagement
permission is provided to require in endpoints or other application actions affecting overall tenants management.
Tenant admin
A global scope tenantadmin
permission is provided to require in endpoints or other application actions affecting management of the tenant.
Example
/// <summary>
/// Endpoint message for adding a tenant.
/// </summary>
[RequiresPermission(typeof(TenantsManagementPermission))]
public class AddTenantMessage : IMessage
{
//...
}
/// <summary>
/// Endpoint message for changing the tenant information.
/// </summary>
[RequiresPermission(typeof(TenantAdminPermission))]
public class ChangeTenantInfoMessage : IMessage
{
//...
}
Configuration
Tenant specific
The TenantSettings
are available through the injectable IConfiguration<TenantSettings>
service. It provides:
- DisplayName (string): The tenant's display name.
- Domains (string[]): an array of domain owned by the tenant. These domains are typically used in the authorization process to identify the tenant a user belongs to.
Example
var config = injector.Resolve<IConfiguration<TenantSettings>>();
var settings = config.GetSettings(context);
settings.DisplayName = "My changed name";
await config.UpdateSettingsAsync(settings, context).PreserveThreadingContext();
Tenant management
The TenantsManagementSettings
are available through the injectable IConfiguration<TenantsManagementSettings>
service. It provides:
- GlobalAdmin (GlobalAdminSettings): settings for the global tenants administrator.
- Tenants (TenantSettings[]): list of settings for the application tenants.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Kephas.Abstractions (>= 11.0.0-dev.3)
- Kephas.Configuration (>= 11.0.0-dev.3)
- Kephas.Security (>= 11.0.0-dev.3)
-
net6.0
- Kephas.Abstractions (>= 11.0.0-dev.3)
- Kephas.Configuration (>= 11.0.0-dev.3)
- Kephas.Security (>= 11.0.0-dev.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
11.1.0 | 467 | 4/13/2022 |
11.1.0-dev.4 | 134 | 4/6/2022 |
11.1.0-dev.3 | 115 | 3/30/2022 |
11.1.0-dev.2 | 127 | 3/23/2022 |
11.1.0-dev.1 | 113 | 3/23/2022 |
11.0.0 | 463 | 3/11/2022 |
11.0.0-dev.7 | 125 | 3/7/2022 |
11.0.0-dev.6 | 126 | 2/28/2022 |
11.0.0-dev.5 | 124 | 2/26/2022 |
11.0.0-dev.4 | 132 | 2/24/2022 |
11.0.0-dev.3 | 122 | 2/23/2022 |
11.0.0-dev.2 | 127 | 2/18/2022 |
Please check https://github.com/kephas-software/kephas/releases for the change log.
Also check the documentation and the samples from https://github.com/kephas-software/kephas/wiki and https://github.com/kephas-software/kephas/tree/master/Samples.