chore 调整项目结构
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
@ -13,21 +11,16 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" Version="8.3.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="8.0.4" />
|
||||
<PackageReference Include="DistributedLock.Redis" Version="1.0.2" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.DistributedLocking" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Swashbuckle" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite" Version="3.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KonSoft.TenantManagement.Application\KonSoft.TenantManagement.Application.csproj" />
|
||||
<ProjectReference Include="..\KonSoft.TenantManagement.EntityFrameworkCore\KonSoft.TenantManagement.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\KonSoft.TenantManagement.HttpApi\KonSoft.TenantManagement.HttpApi.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "https://localhost:44316",
|
||||
"sslPort": 44316
|
||||
"applicationUrl": "https://localhost:44348",
|
||||
"sslPort": 44348
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
@ -18,7 +18,7 @@
|
||||
"KonSoft.TenantManagement.HttpApi.Host": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:44316",
|
||||
"applicationUrl": "https://localhost:44348",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using KonSoft.TenantManagement.Localization;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Ui.Branding;
|
||||
|
||||
namespace KonSoft.TenantManagement;
|
||||
|
||||
[Dependency(ReplaceServices = true)]
|
||||
public class TenantManagementBrandingProvider : DefaultBrandingProvider
|
||||
{
|
||||
private IStringLocalizer<TenantManagementResource> _localizer;
|
||||
|
||||
public TenantManagementBrandingProvider(IStringLocalizer<TenantManagementResource> localizer)
|
||||
{
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public override string AppName => _localizer["AppName"];
|
||||
}
|
||||
@ -2,32 +2,34 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Medallion.Threading;
|
||||
using Medallion.Threading.Redis;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using KonSoft.TenantManagement.EntityFrameworkCore;
|
||||
using KonSoft.TenantManagement.MultiTenancy;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite.Bundling;
|
||||
using StackExchange.Redis;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using OpenIddict.Validation.AspNetCore;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Account;
|
||||
using Volo.Abp.Account.Web;
|
||||
using Volo.Abp.AspNetCore.MultiTenancy;
|
||||
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy;
|
||||
using Volo.Abp.AspNetCore.Serilog;
|
||||
using Volo.Abp.Autofac;
|
||||
using Volo.Abp.Caching;
|
||||
using Volo.Abp.Caching.StackExchangeRedis;
|
||||
using Volo.Abp.DistributedLocking;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Localization;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.Security.Claims;
|
||||
using Volo.Abp.Swashbuckle;
|
||||
using Volo.Abp.UI.Navigation.Urls;
|
||||
using Volo.Abp.VirtualFileSystem;
|
||||
|
||||
namespace KonSoft.TenantManagement;
|
||||
@ -35,76 +37,35 @@ namespace KonSoft.TenantManagement;
|
||||
[DependsOn(
|
||||
typeof(TenantManagementHttpApiModule),
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpAspNetCoreMultiTenancyModule),
|
||||
typeof(AbpCachingStackExchangeRedisModule),
|
||||
typeof(AbpDistributedLockingModule),
|
||||
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
|
||||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
|
||||
typeof(TenantManagementApplicationModule),
|
||||
typeof(TenantManagementEntityFrameworkCoreModule),
|
||||
typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
|
||||
typeof(AbpAccountWebOpenIddictModule),
|
||||
typeof(AbpAspNetCoreSerilogModule),
|
||||
typeof(AbpSwashbuckleModule)
|
||||
)]
|
||||
public class TenantManagementHttpApiHostModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
PreConfigure<OpenIddictBuilder>(builder =>
|
||||
{
|
||||
builder.AddValidation(options =>
|
||||
{
|
||||
options.AddAudiences("TenantManagement");
|
||||
options.UseLocalServer();
|
||||
options.UseAspNetCore();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
||||
|
||||
ConfigureAuthentication(context);
|
||||
ConfigureBundles();
|
||||
ConfigureUrls(configuration);
|
||||
ConfigureConventionalControllers();
|
||||
ConfigureAuthentication(context, configuration);
|
||||
ConfigureCache(configuration);
|
||||
ConfigureVirtualFileSystem(context);
|
||||
ConfigureDataProtection(context, configuration, hostingEnvironment);
|
||||
ConfigureDistributedLocking(context, configuration);
|
||||
ConfigureCors(context, configuration);
|
||||
ConfigureSwaggerServices(context, configuration);
|
||||
}
|
||||
|
||||
private void ConfigureAuthentication(ServiceConfigurationContext context)
|
||||
private void ConfigureCache(IConfiguration configuration)
|
||||
{
|
||||
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
|
||||
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
|
||||
{
|
||||
options.IsDynamicClaimsEnabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureBundles()
|
||||
{
|
||||
Configure<AbpBundlingOptions>(options =>
|
||||
{
|
||||
options.StyleBundles.Configure(
|
||||
LeptonXLiteThemeBundles.Styles.Global,
|
||||
bundle =>
|
||||
{
|
||||
bundle.AddFiles("/global-styles.css");
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureUrls(IConfiguration configuration)
|
||||
{
|
||||
Configure<AppUrlOptions>(options =>
|
||||
{
|
||||
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
|
||||
options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"]?.Split(',') ?? Array.Empty<string>());
|
||||
|
||||
options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"];
|
||||
options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password";
|
||||
});
|
||||
Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "TenantManagement:"; });
|
||||
}
|
||||
|
||||
private void ConfigureVirtualFileSystem(ServiceConfigurationContext context)
|
||||
@ -139,6 +100,22 @@ public class TenantManagementHttpApiHostModule : AbpModule
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
.AddAbpJwtBearer(options =>
|
||||
{
|
||||
options.Authority = configuration["AuthServer:Authority"];
|
||||
options.RequireHttpsMetadata = configuration.GetValue<bool>("AuthServer:RequireHttpsMetadata");
|
||||
options.Audience = "TenantManagement";
|
||||
});
|
||||
|
||||
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
|
||||
{
|
||||
options.IsDynamicClaimsEnabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddAbpSwaggerGenWithOAuth(
|
||||
@ -155,6 +132,30 @@ public class TenantManagementHttpApiHostModule : AbpModule
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureDataProtection(
|
||||
ServiceConfigurationContext context,
|
||||
IConfiguration configuration,
|
||||
IWebHostEnvironment hostingEnvironment)
|
||||
{
|
||||
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("TenantManagement");
|
||||
if (!hostingEnvironment.IsDevelopment())
|
||||
{
|
||||
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!);
|
||||
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "TenantManagement-Protection-Keys");
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigureDistributedLocking(
|
||||
ServiceConfigurationContext context,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddSingleton<IDistributedLockProvider>(sp =>
|
||||
{
|
||||
var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!);
|
||||
return new RedisDistributedSynchronizationProvider(connection.GetDatabase());
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddCors(options =>
|
||||
@ -186,35 +187,29 @@ public class TenantManagementHttpApiHostModule : AbpModule
|
||||
}
|
||||
|
||||
app.UseAbpRequestLocalization();
|
||||
|
||||
if (!env.IsDevelopment())
|
||||
{
|
||||
app.UseErrorPage();
|
||||
}
|
||||
|
||||
app.UseCorrelationId();
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
app.UseCors();
|
||||
app.UseAuthentication();
|
||||
app.UseAbpOpenIddictValidation();
|
||||
|
||||
if (MultiTenancyConsts.IsEnabled)
|
||||
{
|
||||
app.UseMultiTenancy();
|
||||
}
|
||||
|
||||
app.UseUnitOfWork();
|
||||
app.UseDynamicClaims();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseAbpSwaggerUI(c =>
|
||||
app.UseAbpSwaggerUI(options =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "TenantManagement API");
|
||||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "TenantManagement API");
|
||||
|
||||
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
|
||||
c.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
|
||||
c.OAuthScopes("TenantManagement");
|
||||
var configuration = context.GetConfiguration();
|
||||
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
|
||||
options.OAuthScopes("TenantManagement");
|
||||
});
|
||||
|
||||
app.UseAuditing();
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
module.exports = {
|
||||
aliases: {
|
||||
|
||||
},
|
||||
clean: [
|
||||
|
||||
],
|
||||
mappings: {
|
||||
|
||||
}
|
||||
};
|
||||
@ -1,18 +1,19 @@
|
||||
{
|
||||
"App": {
|
||||
"SelfUrl": "https://localhost:44316",
|
||||
"CorsOrigins": "https://*.TenantManagement.com",
|
||||
"RedirectAllowedUrls": ""
|
||||
"CorsOrigins": "https://*.TenantManagement.com,https://localhost:44332"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "Host=localhost;Port=5432;Database=TenantManagement;User ID=root;Password=myPassword;"
|
||||
},
|
||||
"Redis": {
|
||||
"Configuration": "127.0.0.1"
|
||||
},
|
||||
"AuthServer": {
|
||||
"Authority": "https://localhost:44316",
|
||||
"RequireHttpsMetadata": false,
|
||||
"RequireHttpsMetadata": true,
|
||||
"SwaggerClientId": "TenantManagement_Swagger"
|
||||
},
|
||||
"StringEncryption": {
|
||||
"DefaultPassPhrase": "FUFDAYrpYDaw4Tsl"
|
||||
"DefaultPassPhrase": "NR0sazB47i10Gw6H"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"name": "my-app",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@abp/aspnetcore.mvc.ui.theme.leptonxlite": "~3.3.4"
|
||||
}
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
/* Your Global Styles */
|
||||
|
||||
:root .lpx-brand-logo {
|
||||
--lpx-logo: url('/images/logo/leptonx/logo-light.png');
|
||||
--lpx-logo-icon: url('/images/logo/leptonx/logo-light-thumbnail.png');
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 37 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 9.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB |
Reference in New Issue
Block a user