From 9c8afbec521f010e7904e8fd2b3458b379acdf9c Mon Sep 17 00:00:00 2001 From: colin Date: Mon, 12 Aug 2024 19:38:49 +0800 Subject: [PATCH 1/2] fix(templates): Update module dependency version --- ...PackageName.CompanyName.ProjectName.csproj | 2 +- .../content/Directory.Packages.props | 6 +-- .../appsettings.Development.json | 4 +- ...ProjectNamePermissionDefinitionProvider.cs | 44 +++++++++---------- .../ProjectNamePermissions.cs | 16 +++---- .../ProjectNameSettingAppService.cs | 2 +- .../ProjectNameSettingController.cs | 2 +- 7 files changed, 39 insertions(+), 37 deletions(-) rename aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/{Authorization => Permissions}/ProjectNamePermissionDefinitionProvider.cs (88%) rename aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/{Authorization => Permissions}/ProjectNamePermissions.cs (70%) diff --git a/aspnet-core/templates/PackageName.CompanyName.ProjectName.csproj b/aspnet-core/templates/PackageName.CompanyName.ProjectName.csproj index 850295401..ae82c9869 100644 --- a/aspnet-core/templates/PackageName.CompanyName.ProjectName.csproj +++ b/aspnet-core/templates/PackageName.CompanyName.ProjectName.csproj @@ -3,7 +3,7 @@ net8.0 true LINGYUN.Abp.MicroService.Templates - 8.1.3 + 8.2.1 colin.in@foxmail.com Abp framework micro-service template MIT diff --git a/aspnet-core/templates/content/Directory.Packages.props b/aspnet-core/templates/content/Directory.Packages.props index dce5e2882..f3dc78297 100644 --- a/aspnet-core/templates/content/Directory.Packages.props +++ b/aspnet-core/templates/content/Directory.Packages.props @@ -70,7 +70,7 @@ - + @@ -195,7 +195,7 @@ - + @@ -211,7 +211,7 @@ - + diff --git a/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.DbMigrator/appsettings.Development.json b/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.DbMigrator/appsettings.Development.json index 93f33118f..17a01bb6a 100644 --- a/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.DbMigrator/appsettings.Development.json +++ b/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.DbMigrator/appsettings.Development.json @@ -95,7 +95,9 @@ }, "AuthServer": { "Authority": "http://127.0.0.1:44385/", - "ApiName": "lingyun-abp-application", + "Audience": "lingyun-abp-application", + "MapInboundClaims": false, + "RequireHttpsMetadata": false, "SwaggerClientId": "InternalServiceClient", "SwaggerClientSecret": "1q2w3E*" }, diff --git a/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/Authorization/ProjectNamePermissionDefinitionProvider.cs b/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/Permissions/ProjectNamePermissionDefinitionProvider.cs similarity index 88% rename from aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/Authorization/ProjectNamePermissionDefinitionProvider.cs rename to aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/Permissions/ProjectNamePermissionDefinitionProvider.cs index 487837400..4a170551b 100644 --- a/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/Authorization/ProjectNamePermissionDefinitionProvider.cs +++ b/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/Permissions/ProjectNamePermissionDefinitionProvider.cs @@ -1,22 +1,22 @@ -using PackageName.CompanyName.ProjectName.Localization; -using Volo.Abp.Authorization.Permissions; -using Volo.Abp.Localization; - -namespace PackageName.CompanyName.ProjectName.Authorization; - -public class ProjectNamePermissionDefinitionProvider : PermissionDefinitionProvider -{ - public override void Define(IPermissionDefinitionContext context) - { - var group = context.AddGroup(ProjectNamePermissions.GroupName, L("Permission:ProjectName")); - - group.AddPermission( - ProjectNamePermissions.ManageSettings, - L("Permission:ManageSettings")); - } - - private static LocalizableString L(string name) - { - return LocalizableString.Create(name); - } -} +using PackageName.CompanyName.ProjectName.Localization; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Localization; + +namespace PackageName.CompanyName.ProjectName.Permissions; + +public class ProjectNamePermissionDefinitionProvider : PermissionDefinitionProvider +{ + public override void Define(IPermissionDefinitionContext context) + { + var group = context.AddGroup(ProjectNamePermissions.GroupName, L("Permission:ProjectName")); + + group.AddPermission( + ProjectNamePermissions.ManageSettings, + L("Permission:ManageSettings")); + } + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } +} diff --git a/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/Authorization/ProjectNamePermissions.cs b/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/Permissions/ProjectNamePermissions.cs similarity index 70% rename from aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/Authorization/ProjectNamePermissions.cs rename to aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/Permissions/ProjectNamePermissions.cs index 257d11988..98a957ff9 100644 --- a/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/Authorization/ProjectNamePermissions.cs +++ b/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.Application.Contracts/PackageName/CompanyName/ProjectName/Permissions/ProjectNamePermissions.cs @@ -1,8 +1,8 @@ -namespace PackageName.CompanyName.ProjectName.Authorization; - -public static class ProjectNamePermissions -{ - public const string GroupName = "ProjectName"; - - public const string ManageSettings = GroupName + ".ManageSettings"; -} +namespace PackageName.CompanyName.ProjectName.Permissions; + +public static class ProjectNamePermissions +{ + public const string GroupName = "ProjectName"; + + public const string ManageSettings = GroupName + ".ManageSettings"; +} diff --git a/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.SettingManagement/PackageName/CompanyName/ProjectName/SettingManagement/ProjectNameSettingAppService.cs b/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.SettingManagement/PackageName/CompanyName/ProjectName/SettingManagement/ProjectNameSettingAppService.cs index 52641171c..619fdd3ab 100644 --- a/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.SettingManagement/PackageName/CompanyName/ProjectName/SettingManagement/ProjectNameSettingAppService.cs +++ b/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.SettingManagement/PackageName/CompanyName/ProjectName/SettingManagement/ProjectNameSettingAppService.cs @@ -1,6 +1,6 @@ using LINGYUN.Abp.SettingManagement; using Microsoft.AspNetCore.Authorization; -using PackageName.CompanyName.ProjectName.Authorization; +using PackageName.CompanyName.ProjectName.Permissions; using PackageName.CompanyName.ProjectName.Localization; using System.Threading.Tasks; using Volo.Abp.Application.Services; diff --git a/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.SettingManagement/PackageName/CompanyName/ProjectName/SettingManagement/ProjectNameSettingController.cs b/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.SettingManagement/PackageName/CompanyName/ProjectName/SettingManagement/ProjectNameSettingController.cs index 8e2a69ca3..58df5fe31 100644 --- a/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.SettingManagement/PackageName/CompanyName/ProjectName/SettingManagement/ProjectNameSettingController.cs +++ b/aspnet-core/templates/content/src/PackageName.CompanyName.ProjectName.SettingManagement/PackageName/CompanyName/ProjectName/SettingManagement/ProjectNameSettingController.cs @@ -2,7 +2,7 @@ using LINGYUN.Abp.SettingManagement; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using PackageName.CompanyName.ProjectName.Authorization; +using PackageName.CompanyName.ProjectName.Permissions; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; From e96820290ee36f0a6c17adbe1575d81e9a6707d0 Mon Sep 17 00:00:00 2001 From: colin Date: Thu, 15 Aug 2024 19:14:59 +0800 Subject: [PATCH 2/2] fix(docker): Fix authentication errors when running openiddict on Docker --- .../AuthServerHttpApiHostModule.cs | 8 ++++---- .../appsettings.Development.json | 9 +++++---- .../AuthServerModule.Configure.cs | 4 ++-- .../AuthServerModule.cs | 2 +- .../LY.MicroService.AuthServer.csproj | 2 +- .../BackendAdminHttpApiHostModule.cs | 4 ++-- .../IdentityServerHttpApiHostModule.cs | 4 ++-- ...LocalizationManagementHttpApiHostModule.cs | 2 ++ .../PlatformManagementHttpApiHostModule.cs | 4 ++-- .../RealtimeMessageHttpApiHostModule.cs | 4 ++-- .../TaskManagementHttpApiHostModule.cs | 3 ++- .../WebhooksManagementHttpApiHostModule.cs | 2 +- .../WechatManagementHttpApiHostModule.cs | 2 +- .../WorkflowManagementHttpApiHostModule.cs | 2 +- docker-compose.override.configuration.yml | 20 +++++++++---------- docker-compose.override.yml | 20 +++++++++++++++++++ 16 files changed, 58 insertions(+), 34 deletions(-) diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs index e04fe758c..96538315d 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs @@ -60,13 +60,13 @@ namespace LY.MicroService.AuthServer; typeof(AbpAuthorizationOrganizationUnitsModule), typeof(AbpAuditLoggingElasticsearchModule), typeof(AbpEmailingExceptionHandlingModule), - typeof(AbpAspNetCoreAuthenticationJwtBearerModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpCAPEventBusModule), typeof(AbpHttpClientModule), typeof(AbpAliyunSmsModule), typeof(AbpCachingStackExchangeRedisModule), typeof(AbpLocalizationCultureMapModule), + typeof(AbpAspNetCoreAuthenticationJwtBearerModule), + typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpClaimsMappingModule), @@ -130,12 +130,12 @@ public override void OnApplicationInitialization(ApplicationInitializationContex // 认证 app.UseAuthentication(); app.UseJwtTokenMiddleware(); + // 多租户 + app.UseMultiTenancy(); // 会话 app.UseAbpSession(); // 动态身份 app.UseDynamicClaims(); - // 多租户 - app.UseMultiTenancy(); // 授权 app.UseAuthorization(); // Swagger diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/appsettings.Development.json index a9d65bf62..75ea7083a 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/appsettings.Development.json @@ -9,6 +9,7 @@ "tag": "AuthServer.Admin" }, "App": { + "ShowPii": true, "CorsOrigins": "http://127.0.0.1:3100", "Urls": { "Applications": { @@ -86,7 +87,7 @@ "InstanceName": "LINGYUN.Abp.Application" }, "AuthServer": { - "Authority": "http://127.0.0.1:44385/", + "Authority": "http://127.0.0.1:44385", "Audience": "lingyun-abp-application", "MapInboundClaims": false, "RequireHttpsMetadata": false @@ -103,9 +104,9 @@ "MinimumLevel": { "Default": "Debug", "Override": { - "System": "Warning", - "Microsoft": "Warning", - "DotNetCore": "Debug" + "System": "Information", + "Microsoft": "Information", + "DotNetCore": "Warning" } }, "WriteTo": [ diff --git a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs index f8500b1fc..71ab8a4e3 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs @@ -147,7 +147,7 @@ private void PreConfigureCertificate(IConfiguration configuration, IWebHostEnvir builder.AddEncryptionCertificate(cer); - builder.UseDataProtection(); + // builder.UseDataProtection(); }); } } @@ -181,7 +181,7 @@ private void PreConfigureCertificate(IConfiguration configuration, IWebHostEnvir } - builder.UseDataProtection(); + // builder.UseDataProtection(); // 禁用https builder.UseAspNetCore() diff --git a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs index 541f6cb7e..98de536d8 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs @@ -150,9 +150,9 @@ public override void OnApplicationInitialization(ApplicationInitializationContex app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseAbpOpenIddictValidation(); + app.UseMultiTenancy(); app.UseAbpSession(); app.UseDynamicClaims(); - app.UseMultiTenancy(); app.UseAuthorization(); app.UseAuditing(); app.UseAbpSerilogEnrichers(); diff --git a/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj b/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj index 8f4b88a3f..b135bf021 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj +++ b/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj @@ -35,6 +35,7 @@ +