diff --git a/samples/MicroserviceDemo/MicroserviceDemo.sln b/samples/MicroserviceDemo/MicroserviceDemo.sln
index 311744e4a9..25b547f648 100644
--- a/samples/MicroserviceDemo/MicroserviceDemo.sln
+++ b/samples/MicroserviceDemo/MicroserviceDemo.sln
@@ -63,6 +63,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PublicWebSite.Host", "appli
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TenantManagementService.Host", "microservices\TenantManagementService.Host\TenantManagementService.Host.csproj", "{3E1DDEDA-A897-470F-81C2-5A3AFA6D0B61}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "shared", "shared", "{2B3B460C-0293-44A1-BEF4-91A778CE73CE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MsDemo.Shared", "shared\MsDemo.Shared\MsDemo.Shared.csproj", "{D4549E30-18CC-4157-B994-C0097216C2C8}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -161,6 +165,10 @@ Global
{3E1DDEDA-A897-470F-81C2-5A3AFA6D0B61}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E1DDEDA-A897-470F-81C2-5A3AFA6D0B61}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E1DDEDA-A897-470F-81C2-5A3AFA6D0B61}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D4549E30-18CC-4157-B994-C0097216C2C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D4549E30-18CC-4157-B994-C0097216C2C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D4549E30-18CC-4157-B994-C0097216C2C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D4549E30-18CC-4157-B994-C0097216C2C8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -192,6 +200,7 @@ Global
{BB8FA269-460D-42BE-90A0-E97D6A3FDEB1} = {8F6834D7-E6FA-4A04-83BB-955F68EA0A0A}
{29A3A4EF-DEC4-4E43-B6B8-D565667F85EC} = {8F6834D7-E6FA-4A04-83BB-955F68EA0A0A}
{3E1DDEDA-A897-470F-81C2-5A3AFA6D0B61} = {3B26D176-390B-4F51-BE52-E9B422C28A88}
+ {D4549E30-18CC-4157-B994-C0097216C2C8} = {2B3B460C-0293-44A1-BEF4-91A778CE73CE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {37474F0D-2E52-4D2F-B39B-7FE3FF31B4EC}
diff --git a/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj b/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj
index 73b1f68b7c..eaded7f020 100644
--- a/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj
+++ b/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServer.Host.csproj
@@ -36,6 +36,7 @@
+
diff --git a/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs b/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs
index 6b4bec75af..8a132b2cac 100644
--- a/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs
+++ b/samples/MicroserviceDemo/applications/AuthServer.Host/AuthServerHostModule.cs
@@ -2,6 +2,7 @@ using AuthServer.Host.EntityFrameworkCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
+using MsDemo.Shared;
using StackExchange.Redis;
using Volo.Abp;
using Volo.Abp.Account;
@@ -57,7 +58,7 @@ namespace AuthServer.Host
Configure(options =>
{
- options.IsEnabled = true;
+ options.IsEnabled = MsDemoConsts.IsMultiTenancyEnabled;
});
Configure(options =>
@@ -94,7 +95,10 @@ namespace AuthServer.Host
app.UseCorrelationId();
app.UseVirtualFiles();
app.UseRouting();
- app.UseMultiTenancy();
+ if (MsDemoConsts.IsMultiTenancyEnabled)
+ {
+ app.UseMultiTenancy();
+ }
app.UseIdentityServer();
app.UseAbpRequestLocalization();
app.UseAuditing();
diff --git a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminApp.Host.csproj b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminApp.Host.csproj
index d4f6a9f604..1e1f6b8c90 100644
--- a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminApp.Host.csproj
+++ b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminApp.Host.csproj
@@ -36,6 +36,7 @@
+
diff --git a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs
index 4aa5f9470a..5e710fbc48 100644
--- a/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs
+++ b/samples/MicroserviceDemo/applications/BackendAdminApp.Host/BackendAdminAppHostModule.cs
@@ -7,6 +7,7 @@ using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using ProductManagement;
using StackExchange.Redis;
using Microsoft.OpenApi.Models;
+using MsDemo.Shared;
using Swashbuckle.AspNetCore.Swagger;
using Volo.Abp;
using Volo.Abp.AspNetCore.Authentication.OAuth;
@@ -19,6 +20,7 @@ using Volo.Abp.Identity;
using Volo.Abp.Identity.Web;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement;
using Volo.Abp.TenantManagement;
using Volo.Abp.TenantManagement.Web;
@@ -53,6 +55,11 @@ namespace BackendAdminApp.Host
options.Languages.Add(new LanguageInfo("en", "en", "English"));
});
+ Configure(options =>
+ {
+ options.IsEnabled = MsDemoConsts.IsMultiTenancyEnabled;
+ });
+
context.Services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
@@ -106,6 +113,10 @@ namespace BackendAdminApp.Host
app.UseVirtualFiles();
app.UseRouting();
app.UseAuthentication();
+ if (MsDemoConsts.IsMultiTenancyEnabled)
+ {
+ app.UseMultiTenancy();
+ }
app.UseAuthorization();
app.UseAbpRequestLocalization();
app.UseSwagger();
diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj
index 24b6082352..685038d9c8 100644
--- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj
+++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSite.Host.csproj
@@ -29,6 +29,7 @@
+
diff --git a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs
index 4948995e35..a7e236e2d2 100644
--- a/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs
+++ b/samples/MicroserviceDemo/applications/PublicWebSite.Host/PublicWebSiteHostModule.cs
@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
+using MsDemo.Shared;
using ProductManagement;
using StackExchange.Redis;
using Volo.Abp;
@@ -14,6 +15,7 @@ using Volo.Abp.Autofac;
using Volo.Abp.Http.Client.IdentityModel.Web;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.UI.Navigation;
using Volo.Blogging;
@@ -40,6 +42,11 @@ namespace PublicWebSite.Host
options.Languages.Add(new LanguageInfo("en", "en", "English"));
});
+ Configure(options =>
+ {
+ options.IsEnabled = MsDemoConsts.IsMultiTenancyEnabled;
+ });
+
Configure(options =>
{
options.MenuContributors.Add(new PublicWebSiteMenuContributor());
@@ -90,6 +97,11 @@ namespace PublicWebSite.Host
app.UseVirtualFiles();
app.UseRouting();
app.UseAuthentication();
+ if (MsDemoConsts.IsMultiTenancyEnabled)
+ {
+ app.UseMultiTenancy();
+ }
+ app.UseAuthorization();
app.UseAbpRequestLocalization();
app.UseMvcWithDefaultRouteAndArea();
}
diff --git a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj
index 28cae5c2d3..7757bb5cc6 100644
--- a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj
+++ b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGateway.Host.csproj
@@ -24,6 +24,7 @@
+
@@ -42,6 +43,7 @@
+
diff --git a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs
index d79e085521..bfbfe7f94a 100644
--- a/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs
+++ b/samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/BackendAdminAppGatewayHostModule.cs
@@ -9,8 +9,10 @@ using Ocelot.Middleware;
using ProductManagement;
using StackExchange.Redis;
using Microsoft.OpenApi.Models;
+using MsDemo.Shared;
using Swashbuckle.AspNetCore.Swagger;
using Volo.Abp;
+using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.Autofac;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.SqlServer;
@@ -19,6 +21,7 @@ using Volo.Abp.FeatureManagement.EntityFrameworkCore;
using Volo.Abp.Http.Client.IdentityModel.Web;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.PermissionManagement.HttpApi;
@@ -50,7 +53,8 @@ namespace BackendAdminAppGateway.Host
typeof(AbpTenantManagementHttpApiClientModule),
typeof(AbpFeatureManagementEntityFrameworkCoreModule),
typeof(AbpFeatureManagementApplicationModule),
- typeof(AbpFeatureManagementHttpApiModule)
+ typeof(AbpFeatureManagementHttpApiModule),
+ typeof(AbpAspNetCoreMultiTenancyModule)
)]
public class BackendAdminAppGatewayHostModule : AbpModule
{
@@ -58,6 +62,11 @@ namespace BackendAdminAppGateway.Host
{
var configuration = context.Services.GetConfiguration();
+ Configure(options =>
+ {
+ options.IsEnabled = MsDemoConsts.IsMultiTenancyEnabled;
+ });
+
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
@@ -113,7 +122,10 @@ namespace BackendAdminAppGateway.Host
currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer))));
await next();
});
-
+ if (MsDemoConsts.IsMultiTenancyEnabled)
+ {
+ app.UseMultiTenancy();
+ }
app.UseSwagger();
app.UseSwaggerUI(options =>
{
diff --git a/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj b/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj
index 5c2506f6c2..c393685128 100644
--- a/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj
+++ b/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGateway.Host.csproj
@@ -1,4 +1,4 @@
-
+
netcoreapp3.1
@@ -24,6 +24,7 @@
+
@@ -31,6 +32,7 @@
+
diff --git a/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs b/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs
index 01be78ca65..fd72854c6b 100644
--- a/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs
+++ b/samples/MicroserviceDemo/gateways/InternalGateway.Host/InternalGatewayHostModule.cs
@@ -9,13 +9,16 @@ using Ocelot.Middleware;
using ProductManagement;
using StackExchange.Redis;
using Microsoft.OpenApi.Models;
+using MsDemo.Shared;
using Swashbuckle.AspNetCore.Swagger;
using Volo.Abp;
+using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.Autofac;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
@@ -32,7 +35,8 @@ namespace InternalGateway.Host
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
- typeof(AbpTenantManagementHttpApiModule)
+ typeof(AbpTenantManagementHttpApiModule),
+ typeof(AbpAspNetCoreMultiTenancyModule)
)]
public class InternalGatewayHostModule : AbpModule
{
@@ -40,6 +44,11 @@ namespace InternalGateway.Host
{
var configuration = context.Services.GetConfiguration();
+ Configure(options =>
+ {
+ options.IsEnabled = MsDemoConsts.IsMultiTenancyEnabled;
+ });
+
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
@@ -95,7 +104,10 @@ namespace InternalGateway.Host
currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer))));
await next();
});
-
+ if (MsDemoConsts.IsMultiTenancyEnabled)
+ {
+ app.UseMultiTenancy();
+ }
app.UseSwagger();
app.UseSwaggerUI(options =>
{
diff --git a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGateway.Host.csproj b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGateway.Host.csproj
index 82f3b5440b..fb06bcea05 100644
--- a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGateway.Host.csproj
+++ b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGateway.Host.csproj
@@ -24,11 +24,13 @@
+
+
diff --git a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGatewayHostModule.cs b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGatewayHostModule.cs
index 0129663e5a..85abd1211c 100644
--- a/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGatewayHostModule.cs
+++ b/samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/PublicWebSiteGatewayHostModule.cs
@@ -9,12 +9,15 @@ using Ocelot.Middleware;
using ProductManagement;
using StackExchange.Redis;
using Microsoft.OpenApi.Models;
+using MsDemo.Shared;
using Swashbuckle.AspNetCore.Swagger;
using Volo.Abp;
+using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.Autofac;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.Modularity;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
@@ -28,7 +31,8 @@ namespace PublicWebSiteGateway.Host
typeof(ProductManagementHttpApiModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
- typeof(AbpSettingManagementEntityFrameworkCoreModule)
+ typeof(AbpSettingManagementEntityFrameworkCoreModule),
+ typeof(AbpAspNetCoreMultiTenancyModule)
)]
public class PublicWebSiteGatewayHostModule : AbpModule
{
@@ -36,6 +40,11 @@ namespace PublicWebSiteGateway.Host
{
var configuration = context.Services.GetConfiguration();
+ Configure(options =>
+ {
+ options.IsEnabled = MsDemoConsts.IsMultiTenancyEnabled;
+ });
+
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
@@ -91,7 +100,10 @@ namespace PublicWebSiteGateway.Host
currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer))));
await next();
});
-
+ if (MsDemoConsts.IsMultiTenancyEnabled)
+ {
+ app.UseMultiTenancy();
+ }
app.UseSwagger();
app.UseSwaggerUI(options =>
{
diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj
index 024d64a5e4..1a107bcf40 100644
--- a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj
+++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingService.Host.csproj
@@ -23,6 +23,7 @@
+
@@ -34,6 +35,7 @@
+
diff --git a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs
index b72a4f56a6..3b10225ef9 100644
--- a/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs
+++ b/samples/MicroserviceDemo/microservices/BloggingService.Host/BloggingServiceHostModule.cs
@@ -9,8 +9,10 @@ using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
using StackExchange.Redis;
using Microsoft.OpenApi.Models;
+using MsDemo.Shared;
using Swashbuckle.AspNetCore.Swagger;
using Volo.Abp;
+using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.Auditing;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Autofac;
@@ -23,6 +25,7 @@ using Volo.Abp.Http.Client.IdentityModel.Web;
using Volo.Abp.Identity;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
@@ -45,7 +48,8 @@ namespace BloggingService.Host
typeof(BloggingMongoDbModule),
typeof(BloggingApplicationModule),
typeof(AbpHttpClientIdentityModelWebModule),
- typeof(AbpIdentityHttpApiClientModule)
+ typeof(AbpIdentityHttpApiClientModule),
+ typeof(AbpAspNetCoreMultiTenancyModule)
)]
public class BloggingServiceHostModule : AbpModule
{
@@ -54,6 +58,11 @@ namespace BloggingService.Host
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
+ Configure(options =>
+ {
+ options.IsEnabled = MsDemoConsts.IsMultiTenancyEnabled;
+ });
+
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
@@ -123,7 +132,10 @@ namespace BloggingService.Host
currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer))));
await next();
});
-
+ if (MsDemoConsts.IsMultiTenancyEnabled)
+ {
+ app.UseMultiTenancy();
+ }
app.UseAbpRequestLocalization(); //TODO: localization?
app.UseSwagger();
app.UseSwaggerUI(options =>
diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj
index 11f7485be2..9bab4d252f 100644
--- a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj
+++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj
@@ -23,6 +23,7 @@
+
@@ -31,6 +32,7 @@
+
diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs
index 2bf102a465..a9648a6748 100644
--- a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs
+++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs
@@ -6,8 +6,10 @@ using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
using StackExchange.Redis;
using Microsoft.OpenApi.Models;
+using MsDemo.Shared;
using Swashbuckle.AspNetCore.Swagger;
using Volo.Abp;
+using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.Auditing;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Autofac;
@@ -18,6 +20,7 @@ using Volo.Abp.Identity;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
@@ -33,7 +36,8 @@ namespace IdentityService.Host
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
- typeof(AbpIdentityApplicationModule)
+ typeof(AbpIdentityApplicationModule),
+ typeof(AbpAspNetCoreMultiTenancyModule)
)]
public class IdentityServiceHostModule : AbpModule
{
@@ -41,6 +45,11 @@ namespace IdentityService.Host
{
var configuration = context.Services.GetConfiguration();
+ Configure(options =>
+ {
+ options.IsEnabled = MsDemoConsts.IsMultiTenancyEnabled;
+ });
+
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
@@ -90,7 +99,10 @@ namespace IdentityService.Host
app.UseVirtualFiles();
app.UseRouting();
app.UseAuthentication();
-
+ if (MsDemoConsts.IsMultiTenancyEnabled)
+ {
+ app.UseMultiTenancy();
+ }
app.Use(async (ctx, next) =>
{
var currentPrincipalAccessor = ctx.RequestServices.GetRequiredService();
diff --git a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductService.Host.csproj b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductService.Host.csproj
index 133a7f70b6..21750c55de 100644
--- a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductService.Host.csproj
+++ b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductService.Host.csproj
@@ -24,6 +24,7 @@
+
@@ -32,6 +33,7 @@
+
diff --git a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs
index 97235133f9..92993809b4 100644
--- a/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs
+++ b/samples/MicroserviceDemo/microservices/ProductService.Host/ProductServiceHostModule.cs
@@ -8,8 +8,10 @@ using ProductManagement;
using ProductManagement.EntityFrameworkCore;
using StackExchange.Redis;
using Microsoft.OpenApi.Models;
+using MsDemo.Shared;
using Swashbuckle.AspNetCore.Swagger;
using Volo.Abp;
+using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.Auditing;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Autofac;
@@ -19,6 +21,7 @@ using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.EventBus.RabbitMq;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
@@ -35,7 +38,8 @@ namespace ProductService.Host
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(ProductManagementApplicationModule),
typeof(ProductManagementHttpApiModule),
- typeof(ProductManagementEntityFrameworkCoreModule)
+ typeof(ProductManagementEntityFrameworkCoreModule),
+ typeof(AbpAspNetCoreMultiTenancyModule)
)]
public class ProductServiceHostModule : AbpModule
{
@@ -43,6 +47,11 @@ namespace ProductService.Host
{
var configuration = context.Services.GetConfiguration();
+ Configure(options =>
+ {
+ options.IsEnabled = MsDemoConsts.IsMultiTenancyEnabled;
+ });
+
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
@@ -107,7 +116,10 @@ namespace ProductService.Host
currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer))));
await next();
});
-
+ if (MsDemoConsts.IsMultiTenancyEnabled)
+ {
+ app.UseMultiTenancy();
+ }
app.UseAbpRequestLocalization(); //TODO: localization?
app.UseSwagger();
app.UseSwaggerUI(options =>
diff --git a/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementService.Host.csproj b/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementService.Host.csproj
index c900402598..078c067cf1 100644
--- a/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementService.Host.csproj
+++ b/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementService.Host.csproj
@@ -1,4 +1,4 @@
-
+
netcoreapp3.1
@@ -23,6 +23,7 @@
+
@@ -31,6 +32,7 @@
+
diff --git a/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs b/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs
index 43de1b2a3a..9128fdd720 100644
--- a/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs
+++ b/samples/MicroserviceDemo/microservices/TenantManagementService.Host/TenantManagementServiceHostModule.cs
@@ -5,8 +5,10 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
+using MsDemo.Shared;
using StackExchange.Redis;
using Volo.Abp;
+using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.Auditing;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Autofac;
@@ -15,6 +17,7 @@ using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.EventBus.RabbitMq;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
@@ -32,7 +35,8 @@ namespace TenantManagementService.Host
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpTenantManagementHttpApiModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule),
- typeof(AbpTenantManagementApplicationModule)
+ typeof(AbpTenantManagementApplicationModule),
+ typeof(AbpAspNetCoreMultiTenancyModule)
)]
public class TenantManagementServiceHostModule : AbpModule
{
@@ -40,6 +44,11 @@ namespace TenantManagementService.Host
{
var configuration = context.Services.GetConfiguration();
+ Configure(options =>
+ {
+ options.IsEnabled = MsDemoConsts.IsMultiTenancyEnabled;
+ });
+
context.Services.AddAuthentication("Bearer")
.AddIdentityServerAuthentication(options =>
{
@@ -104,7 +113,10 @@ namespace TenantManagementService.Host
currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer))));
await next();
});
-
+ if (MsDemoConsts.IsMultiTenancyEnabled)
+ {
+ app.UseMultiTenancy();
+ }
app.UseAbpRequestLocalization(); //TODO: localization?
app.UseSwagger();
app.UseSwaggerUI(options =>
diff --git a/samples/MicroserviceDemo/shared/MsDemo.Shared/MsDemo.Shared.csproj b/samples/MicroserviceDemo/shared/MsDemo.Shared/MsDemo.Shared.csproj
new file mode 100644
index 0000000000..cb63190696
--- /dev/null
+++ b/samples/MicroserviceDemo/shared/MsDemo.Shared/MsDemo.Shared.csproj
@@ -0,0 +1,7 @@
+
+
+
+ netcoreapp3.1
+
+
+
diff --git a/samples/MicroserviceDemo/shared/MsDemo.Shared/MsDemoConsts.cs b/samples/MicroserviceDemo/shared/MsDemo.Shared/MsDemoConsts.cs
new file mode 100644
index 0000000000..4b9c7406ce
--- /dev/null
+++ b/samples/MicroserviceDemo/shared/MsDemo.Shared/MsDemoConsts.cs
@@ -0,0 +1,7 @@
+namespace MsDemo.Shared
+{
+ public class MsDemoConsts
+ {
+ public const bool IsMultiTenancyEnabled = true;
+ }
+}