From 8e7953315ac3678d5c820e3ea528b9a58d090f6d Mon Sep 17 00:00:00 2001 From: colin Date: Mon, 21 Sep 2026 18:04:37 +0800 Subject: [PATCH] feat: Refactor the session module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 `AbpIdentityAspNetCoreSessionModule` 模块,相关功能移动到`AbpAccountWebOpenIddictModule`、`AbpAccountWebIdentityServerModule`模块 - 移除 `AbpIdentitySessionAspNetCoreModule` 模块,此模块中间件无意义 - 移除 `AbpIdentityServerSessionModule` 模块,相关功能移动到`AbpAccountWebIdentityServerModule`模块 - 移除 `AbpOpenIddictAspNetCoreSessionModule` 模块,相关功能移动到`AbpAccountWebOpenIddictModule` 模块 - 增加 `AbpAspNetCoreSessionModule` 模块,实现动态会话检测与设备解析功能 - 全部启动模块更换为使用 `AbpAspNetCoreSessionModule` 模块进行会话检查 - 全部启动模块移除 `app.UseAbpSession()` 中间件 --- aspnet-core/LINGYUN.MicroService.All.slnx | 18 ++- aspnet-core/LINGYUN.MicroService.Aspire.slnx | 5 +- .../LINGYUN.MicroService.SingleProject.slnx | 12 +- .../AIServiceModule.Configure.cs | 3 - .../AIServiceModule.cs | 5 +- .../LINGYUN.Abp.MicroService.AIService.csproj | 2 +- .../Program.cs | 5 +- .../AdminServiceModule.cs | 5 +- ...NGYUN.Abp.MicroService.AdminService.csproj | 2 +- .../Program.cs | 3 - .../AuthServerModule.Configure.cs | 17 --- .../AuthServerModule.cs | 9 +- ...LINGYUN.Abp.MicroService.AuthServer.csproj | 4 +- .../Program.cs | 4 +- .../appsettings.Development.json | 3 +- .../IdentitySessionAccessEventHandler.cs | 6 +- .../IdentityServiceModule.cs | 4 +- ...UN.Abp.MicroService.IdentityService.csproj | 2 +- .../Program.cs | 5 +- .../appsettings.Development.json | 6 +- ...bp.MicroService.LocalizationService.csproj | 2 +- .../LocalizationServiceModule.cs | 4 +- .../Program.cs | 5 +- ...YUN.Abp.MicroService.MessageService.csproj | 2 +- .../MessageServiceModule.cs | 4 +- .../Program.cs | 5 +- ...UN.Abp.MicroService.PlatformService.csproj | 2 +- .../PlatformServiceModule.cs | 6 +- .../Program.cs | 2 - ...INGYUN.Abp.MicroService.TaskService.csproj | 1 + .../TaskServiceModule.cs | 2 + ...GYUN.Abp.MicroService.WeChatService.csproj | 2 +- .../Program.cs | 4 +- .../WeChatServiceModule.cs | 4 +- ...YUN.Abp.MicroService.WebhookService.csproj | 2 +- .../Program.cs | 4 +- .../WebhookServiceModule.cs | 4 +- ...UN.Abp.MicroService.WorkflowService.csproj | 2 +- .../Program.cs | 4 +- .../WorkflowServiceModule.cs | 4 +- .../Abp/AuditLogging/AbpAuditLoggingModule.cs | 11 ++ .../FodyWeavers.xml | 0 .../FodyWeavers.xsd | 0 .../LINGYUN.Abp.AspNetCore.Session.csproj} | 8 +- .../Session/AbpAspNetCoreSessionModule.cs | 15 +++ .../Session/AbpAspNetCoreSessionOptions.cs} | 7 +- ...essionDynamicClaimsPrincipalContributor.cs | 6 +- .../Session}/HttpContextDeviceInfoProvider.cs | 12 +- .../AbpAccountWebIdentityServerModule.cs | 24 +++- .../AbpIdentitySessionEventServiceHandler.cs | 102 ++++++++++++++++ ...IdentitySessionUserInfoRequestValidator.cs | 8 +- .../Handlers}/Constants.cs | 2 +- ...ntityServerSessionAuthenticationService.cs | 114 ++++++++++++++++++ .../System/StringsExtensions.cs | 0 .../AbpAccountWebOpenIddictModule.cs | 24 +++- .../Controllers/AuthorizeController.cs | 28 ++++- .../ProcessSignOutIdentitySession.cs | 14 ++- .../Handlers}/RevocationIdentitySession.cs | 2 +- ...rverValidationTokenCheckIdentitySession.cs | 25 ++-- .../ValidationTokenCheckIdentitySession.cs | 4 +- .../OpenIddictSessionAuthenticationService.cs | 114 ++++++++++++++++++ ...YUN.Abp.Identity.AspNetCore.Session.csproj | 24 ---- .../AbpIdentityAspNetCoreSessionModule.cs | 26 ---- ...AbpIdentitySessionAuthenticationService.cs | 58 --------- .../README.EN.md | 67 ---------- .../README.md | 67 ---------- .../Session/IIdentitySessionManager.cs | 11 ++ ...entitySessionClaimsPrincipalContributor.cs | 38 ------ .../Session/IdentitySessionManager.cs | 19 ++- .../Session/IdentitySessionSignInOptions.cs | 31 ----- .../FodyWeavers.xml | 3 - .../FodyWeavers.xsd | 30 ----- .../AbpIdentitySessionAspNetCoreModule.cs | 12 -- .../AbpSessionApplicationBuilderExtensions.cs | 22 ---- .../AspNetCore/AbpSessionMiddleware.cs | 42 ------- .../README.EN.md | 97 --------------- .../README.md | 98 --------------- .../Session/DefaultIdentitySessionChecker.cs | 14 +-- .../Session/DefaultSessionInfoProvider.cs | 1 + .../Identity/Session/ISessionInfoProvider.cs | 2 + .../FodyWeavers.xml | 3 - .../FodyWeavers.xsd | 30 ----- .../LINGYUN.Abp.IdentityServer.Session.csproj | 22 ---- .../Session/AbpIdentityServerSessionModule.cs | 42 ------- .../AbpIdentitySessionEventServiceHandler.cs | 102 ---------------- .../README.EN.md | 77 ------------ .../README.md | 77 ------------ .../FodyWeavers.xml | 3 - .../FodyWeavers.xsd | 30 ----- ...N.Abp.OpenIddict.AspNetCore.Session.csproj | 25 ---- .../AbpOpenIddictAspNetCoreSessionModule.cs | 54 --------- .../AbpOpenIddictAspNetCoreSessionOptions.cs | 14 --- .../Session/ProcessSignInIdentitySession.cs | 56 --------- .../Session/UserinfoIdentitySession.cs | 49 -------- .../README.EN.md | 76 ------------ .../README.md | 76 ------------ .../Scriban/ScribanTemplateRenderingEngine.cs | 1 + .../GlobalUsings.cs | 9 +- ...LY.MicroService.Applications.Single.csproj | 4 +- ...rviceApplicationsSingleModule.Configure.cs | 13 +- .../MicroServiceApplicationsSingleModule.cs | 8 +- .../Program.cs | 19 ++- .../AuthServerHttpApiHostModule.cs | 6 +- ...icroService.AuthServer.HttpApi.Host.csproj | 2 +- .../AuthServerModule.Configure.cs | 16 --- .../AuthServerModule.cs | 14 +-- .../LY.MicroService.AuthServer.csproj | 6 +- .../BackendAdminHttpApiHostModule.cs | 9 +- ...roService.BackendAdmin.HttpApi.Host.csproj | 2 +- ...LocalizationManagement.HttpApi.Host.csproj | 2 +- ...LocalizationManagementHttpApiHostModule.cs | 5 +- ...ice.PlatformManagement.HttpApi.Host.csproj | 2 +- .../PlatformManagementHttpApiHostModule.cs | 5 +- ...ervice.RealtimeMessage.HttpApi.Host.csproj | 2 +- .../RealtimeMessageHttpApiHostModule.cs | 5 +- ...Service.TaskManagement.HttpApi.Host.csproj | 1 + .../TaskManagementHttpApiHostModule.cs | 2 + ...ice.WebhooksManagement.HttpApi.Host.csproj | 2 +- .../WebhooksManagementHttpApiHostModule.cs | 5 +- ...rvice.WechatManagement.HttpApi.Host.csproj | 2 +- .../WechatManagementHttpApiHostModule.cs | 5 +- ...ice.WorkflowManagement.HttpApi.Host.csproj | 2 +- .../WorkflowManagementHttpApiHostModule.cs | 5 +- ...GYUN.MicroService.Internal.ApiGateway.slnx | 8 +- ...INGYUN.MicroService.OpenApi.Gateway.csproj | 4 +- .../OpenApiGatewayModule.cs | 8 +- 126 files changed, 649 insertions(+), 1628 deletions(-) rename aspnet-core/{modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session => framework/common/LINGYUN.Abp.AspNetCore.Session}/FodyWeavers.xml (100%) rename aspnet-core/{modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session => framework/common/LINGYUN.Abp.AspNetCore.Session}/FodyWeavers.xsd (100%) rename aspnet-core/{modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN.Abp.Identity.Session.AspNetCore.csproj => framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN.Abp.AspNetCore.Session.csproj} (63%) create mode 100644 aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/AbpAspNetCoreSessionModule.cs rename aspnet-core/{modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpIdentitySessionAspNetCoreOptions.cs => framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/AbpAspNetCoreSessionOptions.cs} (53%) rename aspnet-core/{modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore => framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session}/AbpIdentitySessionDynamicClaimsPrincipalContributor.cs (92%) rename aspnet-core/{modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore => framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session}/HttpContextDeviceInfoProvider.cs (94%) create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Handlers/AbpIdentitySessionEventServiceHandler.cs rename aspnet-core/modules/{identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session => account/LINGYUN.Abp.Account.Web.IdentityServer/Handlers}/AbpIdentitySessionUserInfoRequestValidator.cs (97%) rename aspnet-core/modules/{identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session => account/LINGYUN.Abp.Account.Web.IdentityServer/Handlers}/Constants.cs (95%) create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Services/IdentityServerSessionAuthenticationService.cs rename aspnet-core/modules/{identityServer/LINGYUN.Abp.IdentityServer.Session => account/LINGYUN.Abp.Account.Web.IdentityServer}/System/StringsExtensions.cs (100%) rename aspnet-core/modules/{openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session => account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers}/ProcessSignOutIdentitySession.cs (81%) rename aspnet-core/modules/{openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session => account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers}/RevocationIdentitySession.cs (97%) rename aspnet-core/modules/{openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session => account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers}/ServerValidationTokenCheckIdentitySession.cs (72%) rename aspnet-core/modules/{openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session => account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers}/ValidationTokenCheckIdentitySession.cs (97%) create mode 100644 aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Services/OpenIddictSessionAuthenticationService.cs delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/LINGYUN.Abp.Identity.AspNetCore.Session.csproj delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/LINGYUN/Abp/Identity/AspNetCore/Session/AbpIdentityAspNetCoreSessionModule.cs delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/LINGYUN/Abp/Identity/AspNetCore/Session/AbpIdentitySessionAuthenticationService.cs delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/README.EN.md delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/README.md delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionClaimsPrincipalContributor.cs delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionSignInOptions.cs delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/FodyWeavers.xml delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/FodyWeavers.xsd delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpIdentitySessionAspNetCoreModule.cs delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpSessionApplicationBuilderExtensions.cs delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpSessionMiddleware.cs delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/README.EN.md delete mode 100644 aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/README.md delete mode 100644 aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/FodyWeavers.xml delete mode 100644 aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/FodyWeavers.xsd delete mode 100644 aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN.Abp.IdentityServer.Session.csproj delete mode 100644 aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/AbpIdentityServerSessionModule.cs delete mode 100644 aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/AbpIdentitySessionEventServiceHandler.cs delete mode 100644 aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/README.EN.md delete mode 100644 aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/README.md delete mode 100644 aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/FodyWeavers.xml delete mode 100644 aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/FodyWeavers.xsd delete mode 100644 aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN.Abp.OpenIddict.AspNetCore.Session.csproj delete mode 100644 aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/AbpOpenIddictAspNetCoreSessionModule.cs delete mode 100644 aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/AbpOpenIddictAspNetCoreSessionOptions.cs delete mode 100644 aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ProcessSignInIdentitySession.cs delete mode 100644 aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/UserinfoIdentitySession.cs delete mode 100644 aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/README.EN.md delete mode 100644 aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/README.md diff --git a/aspnet-core/LINGYUN.MicroService.All.slnx b/aspnet-core/LINGYUN.MicroService.All.slnx index fb77585ea..5471923fa 100644 --- a/aspnet-core/LINGYUN.MicroService.All.slnx +++ b/aspnet-core/LINGYUN.MicroService.All.slnx @@ -93,6 +93,11 @@ + + + + + @@ -123,8 +128,6 @@ - - @@ -147,8 +150,8 @@ - + @@ -295,8 +298,10 @@ + + @@ -328,6 +333,10 @@ + + + + @@ -371,7 +380,6 @@ - @@ -380,7 +388,6 @@ - @@ -396,7 +403,6 @@ - diff --git a/aspnet-core/LINGYUN.MicroService.Aspire.slnx b/aspnet-core/LINGYUN.MicroService.Aspire.slnx index 580e01436..2f2febe79 100644 --- a/aspnet-core/LINGYUN.MicroService.Aspire.slnx +++ b/aspnet-core/LINGYUN.MicroService.Aspire.slnx @@ -109,6 +109,7 @@ + @@ -360,7 +361,6 @@ - @@ -370,7 +370,6 @@ - @@ -381,7 +380,6 @@ - @@ -397,7 +395,6 @@ - diff --git a/aspnet-core/LINGYUN.MicroService.SingleProject.slnx b/aspnet-core/LINGYUN.MicroService.SingleProject.slnx index 1b3533f6c..78c0fe4bf 100644 --- a/aspnet-core/LINGYUN.MicroService.SingleProject.slnx +++ b/aspnet-core/LINGYUN.MicroService.SingleProject.slnx @@ -1,6 +1,5 @@ - @@ -14,6 +13,10 @@ + + + + @@ -112,6 +115,9 @@ + + + @@ -268,7 +274,6 @@ - @@ -276,7 +281,6 @@ - @@ -284,7 +288,6 @@ - @@ -321,7 +324,6 @@ - diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/AIServiceModule.Configure.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/AIServiceModule.Configure.cs index 695cd4fef..c652dc8e0 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/AIServiceModule.Configure.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/AIServiceModule.Configure.cs @@ -387,9 +387,6 @@ public partial class AIServiceModule options.TokenCookie.SameSite = SameSiteMode.Lax; }); - services.AddAlwaysAllowAuthorization(); - services.AddAlwaysAllowSession(); - services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddAbpJwtBearer(options => { diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/AIServiceModule.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/AIServiceModule.cs index f79ca31ac..118ea082a 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/AIServiceModule.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/AIServiceModule.cs @@ -5,6 +5,7 @@ using LINGYUN.Abp.AI.Tools.Mcp; using LINGYUN.Abp.AIManagement; using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Claims.Mapping; using LINGYUN.Abp.Data.DbMigrator; @@ -12,7 +13,6 @@ using LINGYUN.Abp.Dynamic.Definitions; using LINGYUN.Abp.Emailing.Platform; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Emailing; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.Logging.Serilog.Elasticsearch; @@ -48,8 +48,6 @@ namespace LINGYUN.Abp.MicroService.AIService; // 重写模板引擎支持外部本地化 typeof(AbpTextTemplatingScribanModule), - typeof(AbpIdentitySessionAspNetCoreModule), - typeof(AbpAIOllamaModule), typeof(AbpAIToolsModule), typeof(AbpAIToolsHttpModule), @@ -66,6 +64,7 @@ namespace LINGYUN.Abp.MicroService.AIService; typeof(AbpEmailingPlatformModule), typeof(AbpCachingStackExchangeRedisModule), typeof(AbpLocalizationCultureMapModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/LINGYUN.Abp.MicroService.AIService.csproj b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/LINGYUN.Abp.MicroService.AIService.csproj index 30335f0d9..a64a7f6fd 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/LINGYUN.Abp.MicroService.AIService.csproj +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/LINGYUN.Abp.MicroService.AIService.csproj @@ -42,6 +42,7 @@ + @@ -63,7 +64,6 @@ - diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/Program.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/Program.cs index 85b652951..e4fc4347c 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/Program.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AIService/Program.cs @@ -1,5 +1,4 @@ -using LINGYUN.Abp.Identity.Session.AspNetCore; -using LINGYUN.Abp.MicroService.AIService; +using LINGYUN.Abp.MicroService.AIService; using LINGYUN.Abp.Serilog.Enrichers.Application; using Serilog; using Volo.Abp.IO; @@ -59,8 +58,6 @@ try app.UseJwtTokenMiddleware(); // 多租户 app.UseMultiTenancy(); - // 会话 - app.UseAbpSession(); // jwt app.UseDynamicClaims(); // 授权 diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService/AdminServiceModule.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService/AdminServiceModule.cs index f2b32418c..c3d213a68 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService/AdminServiceModule.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService/AdminServiceModule.cs @@ -1,6 +1,7 @@ using LINGYUN.Abp.Aliyun.SettingManagement; using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.Auditing; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.BlobManagement.SettingManagement; @@ -15,7 +16,6 @@ using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.FeatureManagement; using LINGYUN.Abp.FeatureManagement.HttpApi; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.Logging.Serilog.Elasticsearch; using LINGYUN.Abp.PermissionManagement; @@ -86,8 +86,6 @@ namespace LINGYUN.Abp.MicroService.AdminService; // 重写模板引擎支持外部本地化 typeof(AbpTextTemplatingScribanModule), - typeof(AbpIdentitySessionAspNetCoreModule), - typeof(AdminServiceMigrationsEntityFrameworkCoreModule), typeof(AbpDataDbMigratorModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule), @@ -97,6 +95,7 @@ namespace LINGYUN.Abp.MicroService.AdminService; typeof(AbpEmailingPlatformModule), typeof(AbpCachingStackExchangeRedisModule), typeof(AbpLocalizationCultureMapModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService/LINGYUN.Abp.MicroService.AdminService.csproj b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService/LINGYUN.Abp.MicroService.AdminService.csproj index d70d63fba..3cfdbcef9 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService/LINGYUN.Abp.MicroService.AdminService.csproj +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService/LINGYUN.Abp.MicroService.AdminService.csproj @@ -43,6 +43,7 @@ + @@ -69,7 +70,6 @@ - diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService/Program.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService/Program.cs index a2990eb30..dd64edf9d 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService/Program.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService/Program.cs @@ -1,4 +1,3 @@ -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.MicroService.AdminService; using LINGYUN.Abp.Serilog.Enrichers.Application; using Serilog; @@ -59,8 +58,6 @@ try app.UseJwtTokenMiddleware(); // ¶à×⻧ app.UseMultiTenancy(); - // »Ự - app.UseAbpSession(); // jwt app.UseDynamicClaims(); // ÊÚȨ diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/AuthServerModule.Configure.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/AuthServerModule.Configure.cs index d43000e6d..82f3ba099 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/AuthServerModule.Configure.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/AuthServerModule.Configure.cs @@ -4,14 +4,8 @@ using LINGYUN.Abp.Identity; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement; using LINGYUN.Abp.MicroService.AuthServer.Ui.Branding; -using LINGYUN.Abp.OpenIddict.AspNetCore.Session; using LINGYUN.Abp.OpenIddict.Impersonation; -using LINGYUN.Abp.OpenIddict.LinkUser; -using LINGYUN.Abp.OpenIddict.Portal; -using LINGYUN.Abp.OpenIddict.Sms; -using LINGYUN.Abp.OpenIddict.WeChat; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; -using LINGYUN.Abp.WeChat.Work; using LINGYUN.Abp.Wrapper; using Medallion.Threading; using Medallion.Threading.Redis; @@ -291,17 +285,6 @@ public partial class AuthServerModule options.IsDynamicClaimsEnabled = true; options.IsRemoteRefreshEnabled = false; }); - - Configure(options => - { - options.PersistentSessionGrantTypes.Add(SmsTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(PortalTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(LinkUserTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(ImpersonationTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(WeChatTokenExtensionGrantConsts.OfficialGrantType); - options.PersistentSessionGrantTypes.Add(WeChatTokenExtensionGrantConsts.MiniProgramGrantType); - options.PersistentSessionGrantTypes.Add(AbpWeChatWorkGlobalConsts.GrantType); - }); } private void ConfigureVirtualFileSystem() { diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/AuthServerModule.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/AuthServerModule.cs index 411ac0aef..e5857008d 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/AuthServerModule.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/AuthServerModule.cs @@ -1,5 +1,4 @@ using LINGYUN.Abp.Account; -using LINGYUN.Abp.Account.Web.LazyCaptcha; using LINGYUN.Abp.Account.Web.OAuth; using LINGYUN.Abp.Account.Web.OpenIddict; using LINGYUN.Abp.Account.Web.TencentCaptcha; @@ -7,6 +6,7 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.MultiTenancy; using LINGYUN.Abp.AspNetCore.Mvc.UI.MultiTenancy; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.BlobStoring.BlobManagement; using LINGYUN.Abp.Data.DbMigrator; @@ -17,11 +17,8 @@ using LINGYUN.Abp.Exporter.MiniSoftware; using LINGYUN.Abp.Gdpr; using LINGYUN.Abp.Gdpr.Web; using LINGYUN.Abp.Identity.AspNetCore; -using LINGYUN.Abp.Identity.AspNetCore.Session; using LINGYUN.Abp.Identity.OrganizaztionUnits; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; -using LINGYUN.Abp.OpenIddict.AspNetCore.Session; using LINGYUN.Abp.OpenIddict.Impersonation; using LINGYUN.Abp.OpenIddict.LinkUser; using LINGYUN.Abp.OpenIddict.Portal; @@ -64,9 +61,6 @@ namespace LINGYUN.Abp.MicroService.AuthServer; typeof(AbpAutofacModule), typeof(AbpCachingStackExchangeRedisModule), typeof(AbpIdentityAspNetCoreModule), - typeof(AbpIdentityAspNetCoreSessionModule), - typeof(AbpOpenIddictAspNetCoreSessionModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpOpenIddictSmsModule), typeof(AbpOpenIddictWeChatModule), typeof(AbpOpenIddictLinkUserModule), @@ -80,6 +74,7 @@ namespace LINGYUN.Abp.MicroService.AuthServer; typeof(AbpAuditLoggingElasticsearchModule), // 放在 AbpIdentity 模块之后,避免被覆盖 typeof(AbpLocalizationCultureMapModule), typeof(AbpAspNetCoreMultiTenancyModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcUiMultiTenancyModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/LINGYUN.Abp.MicroService.AuthServer.csproj b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/LINGYUN.Abp.MicroService.AuthServer.csproj index cdc392d11..b7d09e557 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/LINGYUN.Abp.MicroService.AuthServer.csproj +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/LINGYUN.Abp.MicroService.AuthServer.csproj @@ -45,6 +45,7 @@ + @@ -72,10 +73,7 @@ - - - diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/Program.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/Program.cs index 31b3ae68e..9d51e1ac8 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/Program.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/Program.cs @@ -1,5 +1,4 @@ -using LINGYUN.Abp.Identity.Session.AspNetCore; -using LINGYUN.Abp.MicroService.AuthServer; +using LINGYUN.Abp.MicroService.AuthServer; using LINGYUN.Abp.Serilog.Enrichers.Application; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -70,7 +69,6 @@ try app.UseAuthentication(); app.UseAbpOpenIddictValidation(); app.UseMultiTenancy(); - app.UseAbpSession(); app.UseUnitOfWork(); app.UseDynamicClaims(); app.UseAuthorization(); diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/appsettings.Development.json b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/appsettings.Development.json index 3381d7435..f6108f850 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/appsettings.Development.json +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.AuthServer/appsettings.Development.json @@ -156,7 +156,8 @@ "System": "Warning", "Microsoft": "Warning", "DotNetCore": "Warning", - "OpenIddict": "Warning" + "OpenIddict": "Warning", + "LINGYUN.Abp.Account": "Debug" } }, "WriteTo": [ diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/Handlers/IdentitySessionAccessEventHandler.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/Handlers/IdentitySessionAccessEventHandler.cs index 1ac81aee3..cef9847af 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/Handlers/IdentitySessionAccessEventHandler.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/Handlers/IdentitySessionAccessEventHandler.cs @@ -4,6 +4,7 @@ using LINGYUN.Abp.Identity.Settings; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using System; +using System.Linq; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.DistributedLocking; @@ -128,7 +129,10 @@ public class IdentitySessionAccessEventHandler : { if (!eventData.IpAddresses.IsNullOrWhiteSpace()) { - idetitySession.SetIpAddresses(eventData.IpAddresses.Split(",")); + var ipAddresses = idetitySession.GetIpAddresses().ToList(); + ipAddresses.RemoveAll(x => x == eventData.IpAddresses); + ipAddresses.Add(eventData.IpAddresses); + idetitySession.SetIpAddresses(ipAddresses); } idetitySession.UpdateLastAccessedTime(eventData.LastAccessed); diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/IdentityServiceModule.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/IdentityServiceModule.cs index d26bce271..3c46dc6c0 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/IdentityServiceModule.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/IdentityServiceModule.cs @@ -1,6 +1,7 @@ using LINGYUN.Abp.Account; using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.BlobStoring.BlobManagement; @@ -16,7 +17,6 @@ using LINGYUN.Abp.Gdpr.Identity; using LINGYUN.Abp.Identity; using LINGYUN.Abp.Identity.AspNetCore; using LINGYUN.Abp.Identity.EntityFrameworkCore; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.OpenIddict; @@ -78,8 +78,8 @@ namespace LINGYUN.Abp.MicroService.IdentityService; typeof(AbpEmailingPlatformModule), typeof(AbpCachingStackExchangeRedisModule), typeof(AbpLocalizationCultureMapModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpDynamicDefinitionsModule), diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/LINGYUN.Abp.MicroService.IdentityService.csproj b/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/LINGYUN.Abp.MicroService.IdentityService.csproj index 3e48b7a45..b1da81375 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/LINGYUN.Abp.MicroService.IdentityService.csproj +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/LINGYUN.Abp.MicroService.IdentityService.csproj @@ -46,6 +46,7 @@ + @@ -65,7 +66,6 @@ - diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/Program.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/Program.cs index cd32d319b..246d0fff9 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/Program.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/Program.cs @@ -1,5 +1,4 @@ -using LINGYUN.Abp.Identity.Session.AspNetCore; -using LINGYUN.Abp.MicroService.IdentityService; +using LINGYUN.Abp.MicroService.IdentityService; using LINGYUN.Abp.Serilog.Enrichers.Application; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -65,8 +64,6 @@ try app.UseAuthentication(); // 多租户 app.UseMultiTenancy(); - // 会话 - app.UseAbpSession(); // 动态身份 app.UseDynamicClaims(); // 授权 diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/appsettings.Development.json b/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/appsettings.Development.json index 70798fab2..34beb06c9 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/appsettings.Development.json +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.IdentityService/appsettings.Development.json @@ -111,10 +111,10 @@ }, "Serilog": { "MinimumLevel": { - "Default": "Debug", + "Default": "Information", "Override": { - "System": "Information", - "Microsoft": "Information", + "System": "Warning", + "Microsoft": "Warning", "DotNetCore": "Warning" } }, diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.LocalizationService/LINGYUN.Abp.MicroService.LocalizationService.csproj b/aspnet-core/aspire/LINGYUN.Abp.MicroService.LocalizationService/LINGYUN.Abp.MicroService.LocalizationService.csproj index 4e9db5189..7333ea61d 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.LocalizationService/LINGYUN.Abp.MicroService.LocalizationService.csproj +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.LocalizationService/LINGYUN.Abp.MicroService.LocalizationService.csproj @@ -39,6 +39,7 @@ + @@ -52,7 +53,6 @@ - diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.LocalizationService/LocalizationServiceModule.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.LocalizationService/LocalizationServiceModule.cs index 9c281e19c..604e61d49 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.LocalizationService/LocalizationServiceModule.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.LocalizationService/LocalizationServiceModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.Claims.Mapping; @@ -7,7 +8,6 @@ using LINGYUN.Abp.Data.DbMigrator; using LINGYUN.Abp.Dynamic.Definitions; using LINGYUN.Abp.Emailing.Platform; using LINGYUN.Abp.EventBus.CAP; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; @@ -52,10 +52,10 @@ namespace LINGYUN.Abp.MicroService.LocalizationService; typeof(AbpCAPEventBusModule), typeof(AbpCachingStackExchangeRedisModule), typeof(AbpLocalizationCultureMapModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpHttpClientModule), typeof(AbpSmsPlatformModule), typeof(AbpEmailingPlatformModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.LocalizationService/Program.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.LocalizationService/Program.cs index bc1cdf330..a042be159 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.LocalizationService/Program.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.LocalizationService/Program.cs @@ -1,5 +1,4 @@ -using LINGYUN.Abp.Identity.Session.AspNetCore; -using LINGYUN.Abp.MicroService.LocalizationService; +using LINGYUN.Abp.MicroService.LocalizationService; using LINGYUN.Abp.MicroService.ServiceDefaults; using LINGYUN.Abp.Serilog.Enrichers.Application; using Microsoft.AspNetCore.Builder; @@ -69,8 +68,6 @@ try app.UseJwtTokenMiddleware(); // 多租户 app.UseMultiTenancy(); - // 会话 - app.UseAbpSession(); app.UseDynamicClaims(); // 授权 app.UseAuthorization(); diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/LINGYUN.Abp.MicroService.MessageService.csproj b/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/LINGYUN.Abp.MicroService.MessageService.csproj index a60e6da90..0970cf77d 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/LINGYUN.Abp.MicroService.MessageService.csproj +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/LINGYUN.Abp.MicroService.MessageService.csproj @@ -42,6 +42,7 @@ + @@ -62,7 +63,6 @@ - diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/MessageServiceModule.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/MessageServiceModule.cs index 7c22d3376..6ef0b8a8d 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/MessageServiceModule.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/MessageServiceModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.BackgroundTasks.DistributedLocking; @@ -13,7 +14,6 @@ using LINGYUN.Abp.ExceptionHandling.Notifications; using LINGYUN.Abp.Features.LimitValidation.Redis; using LINGYUN.Abp.Identity.EntityFrameworkCore; using LINGYUN.Abp.Identity.Notifications; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Identity.WeChat; using LINGYUN.Abp.Identity.WeChat.Work; using LINGYUN.Abp.IM.SignalR; @@ -112,11 +112,11 @@ namespace LINGYUN.Abp.MicroService.MessageService; typeof(AbpFeaturesValidationRedisModule), typeof(AbpCachingStackExchangeRedisModule), typeof(AbpLocalizationCultureMapModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpEmailingPlatformModule), typeof(AbpSmsPlatformModule), typeof(AbpHttpClientModule), typeof(AbpClaimsMappingModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/Program.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/Program.cs index 3a660d399..adaa6af4f 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/Program.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.MessageService/Program.cs @@ -1,5 +1,4 @@ -using LINGYUN.Abp.Identity.Session.AspNetCore; -using LINGYUN.Abp.MicroService.MessageService; +using LINGYUN.Abp.MicroService.MessageService; using LINGYUN.Abp.Serilog.Enrichers.Application; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -66,8 +65,6 @@ try app.UseJwtTokenMiddleware(); // 多租户 app.UseMultiTenancy(); - // 会话 - app.UseAbpSession(); app.UseDynamicClaims(); // 授权 app.UseAuthorization(); diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.PlatformService/LINGYUN.Abp.MicroService.PlatformService.csproj b/aspnet-core/aspire/LINGYUN.Abp.MicroService.PlatformService/LINGYUN.Abp.MicroService.PlatformService.csproj index 4519d7e06..0e3e39c02 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.PlatformService/LINGYUN.Abp.MicroService.PlatformService.csproj +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.PlatformService/LINGYUN.Abp.MicroService.PlatformService.csproj @@ -44,6 +44,7 @@ + @@ -61,7 +62,6 @@ - diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.PlatformService/PlatformServiceModule.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.PlatformService/PlatformServiceModule.cs index 549c19f9b..c99cf96f2 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.PlatformService/PlatformServiceModule.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.PlatformService/PlatformServiceModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.BlobManagement; @@ -15,7 +16,6 @@ using LINGYUN.Abp.Dynamic.Definitions; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.Features.LimitValidation.Redis; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.MicroService.PlatformService.BackgroundWorkers; @@ -89,12 +89,12 @@ namespace LINGYUN.Abp.MicroService.PlatformService; // typeof(AbpFeaturesValidationRedisClientModule),// 当需要客户端特性限制时取消注释此模块 typeof(AbpCachingStackExchangeRedisModule), typeof(AbpLocalizationCultureMapModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpHttpClientModule), typeof(AbpMailKitModule), typeof(AbpAliyunSmsModule), - typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpClaimsMappingModule), + typeof(AbpAspNetCoreSessionModule), + typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), typeof(AbpSwashbuckleModule), diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.PlatformService/Program.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.PlatformService/Program.cs index 53ef7e07e..87bdcade2 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.PlatformService/Program.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.PlatformService/Program.cs @@ -1,4 +1,3 @@ -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.MicroService.PlatformService; using LINGYUN.Abp.Serilog.Enrichers.Application; using Serilog; @@ -60,7 +59,6 @@ try // ¶à×⻧ app.UseMultiTenancy(); // »Ự - app.UseAbpSession(); app.UseDynamicClaims(); // ÊÚȨ app.UseAuthorization(); diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.TaskService/LINGYUN.Abp.MicroService.TaskService.csproj b/aspnet-core/aspire/LINGYUN.Abp.MicroService.TaskService/LINGYUN.Abp.MicroService.TaskService.csproj index 4d8cf5679..0c6981c31 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.TaskService/LINGYUN.Abp.MicroService.TaskService.csproj +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.TaskService/LINGYUN.Abp.MicroService.TaskService.csproj @@ -42,6 +42,7 @@ + diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.TaskService/TaskServiceModule.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.TaskService/TaskServiceModule.cs index 63d2a79fd..5d9c9e354 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.TaskService/TaskServiceModule.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.TaskService/TaskServiceModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.BackgroundTasks.DistributedLocking; @@ -82,6 +83,7 @@ namespace LINGYUN.Abp.MicroService.TaskService; typeof(AbpAspNetCoreMvcModule), typeof(AbpSwashbuckleModule), typeof(AbpLocalizationCultureMapModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WeChatService/LINGYUN.Abp.MicroService.WeChatService.csproj b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WeChatService/LINGYUN.Abp.MicroService.WeChatService.csproj index dd35cd959..a5f1fdf19 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WeChatService/LINGYUN.Abp.MicroService.WeChatService.csproj +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WeChatService/LINGYUN.Abp.MicroService.WeChatService.csproj @@ -43,6 +43,7 @@ + @@ -68,7 +69,6 @@ - diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WeChatService/Program.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WeChatService/Program.cs index 26501397a..7f83d8a4a 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WeChatService/Program.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WeChatService/Program.cs @@ -1,5 +1,4 @@ -using LINGYUN.Abp.Identity.Session.AspNetCore; -using LINGYUN.Abp.MicroService.WeChatService; +using LINGYUN.Abp.MicroService.WeChatService; using LINGYUN.Abp.Serilog.Enrichers.Application; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -57,7 +56,6 @@ app.UseCors(); app.UseAuthentication(); app.UseJwtTokenMiddleware(); app.UseMultiTenancy(); -app.UseAbpSession(); app.UseDynamicClaims(); app.UseAuthorization(); app.UseSwagger(); diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WeChatService/WeChatServiceModule.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WeChatService/WeChatServiceModule.cs index 2f07ff509..a112b0fce 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WeChatService/WeChatServiceModule.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WeChatService/WeChatServiceModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.Claims.Mapping; @@ -7,7 +8,6 @@ using LINGYUN.Abp.Dynamic.Definitions; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.Http.Client.Wrapper; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Identity.WeChat.Work; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.Saas.EntityFrameworkCore; @@ -78,10 +78,10 @@ namespace LINGYUN.Abp.MicroService.WeChatService; typeof(AbpHttpClientWrapperModule), typeof(AbpMailKitModule), typeof(AbpClaimsMappingModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpAutofacModule) )] public partial class WeChatServiceModule : AbpModule diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WebhookService/LINGYUN.Abp.MicroService.WebhookService.csproj b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WebhookService/LINGYUN.Abp.MicroService.WebhookService.csproj index 954443798..3368f468b 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WebhookService/LINGYUN.Abp.MicroService.WebhookService.csproj +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WebhookService/LINGYUN.Abp.MicroService.WebhookService.csproj @@ -37,6 +37,7 @@ + @@ -55,7 +56,6 @@ - diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WebhookService/Program.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WebhookService/Program.cs index 3f7c390a9..ab0cc07f7 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WebhookService/Program.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WebhookService/Program.cs @@ -1,5 +1,4 @@ -using LINGYUN.Abp.Identity.Session.AspNetCore; -using LINGYUN.Abp.MicroService.WebhookService; +using LINGYUN.Abp.MicroService.WebhookService; using LINGYUN.Abp.Serilog.Enrichers.Application; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -59,7 +58,6 @@ try app.UseAuthentication(); app.UseJwtTokenMiddleware(); app.UseMultiTenancy(); - app.UseAbpSession(); app.UseDynamicClaims(); app.UseAuthorization(); app.UseSwagger(); diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WebhookService/WebhookServiceModule.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WebhookService/WebhookServiceModule.cs index eaeb56588..24455c5c0 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WebhookService/WebhookServiceModule.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WebhookService/WebhookServiceModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.BackgroundTasks.DistributedLocking; @@ -11,7 +12,6 @@ using LINGYUN.Abp.Emailing.Platform; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.Http.Client.Wrapper; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; using LINGYUN.Abp.Sms.Platform; @@ -61,10 +61,10 @@ namespace LINGYUN.Abp.MicroService.WebhookService; typeof(AbpClaimsMappingModule), typeof(AbpEmailingPlatformModule), typeof(AbpSmsPlatformModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpAutofacModule) )] public partial class WebhookServiceModule : AbpModule diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/LINGYUN.Abp.MicroService.WorkflowService.csproj b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/LINGYUN.Abp.MicroService.WorkflowService.csproj index df5920d1a..439aaba0d 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/LINGYUN.Abp.MicroService.WorkflowService.csproj +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/LINGYUN.Abp.MicroService.WorkflowService.csproj @@ -48,6 +48,7 @@ + @@ -67,7 +68,6 @@ - diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/Program.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/Program.cs index 42b511467..9f69ea8bb 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/Program.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/Program.cs @@ -1,5 +1,4 @@ -using LINGYUN.Abp.Identity.Session.AspNetCore; -using LINGYUN.Abp.MicroService.WorkflowService; +using LINGYUN.Abp.MicroService.WorkflowService; using LINGYUN.Abp.Serilog.Enrichers.Application; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -58,7 +57,6 @@ app.UseCors(); app.UseAuthentication(); app.UseJwtTokenMiddleware(); app.UseMultiTenancy(); -app.UseAbpSession(); app.UseDynamicClaims(); app.UseAuthorization(); app.UseSwagger(); diff --git a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/WorkflowServiceModule.cs b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/WorkflowServiceModule.cs index dc23b98f5..762933dd4 100644 --- a/aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/WorkflowServiceModule.cs +++ b/aspnet-core/aspire/LINGYUN.Abp.MicroService.WorkflowService/WorkflowServiceModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.BackgroundTasks.DistributedLocking; @@ -16,7 +17,6 @@ using LINGYUN.Abp.Emailing.Platform; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.Http.Client.Wrapper; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.Quartz.PostgresSqlInstaller; @@ -83,10 +83,10 @@ namespace LINGYUN.Abp.MicroService.WorkflowService; typeof(AbpSmsPlatformModule), typeof(AbpEmailingPlatformModule), typeof(AbpClaimsMappingModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcNewtonsoftModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpAutofacModule) )] public partial class WorkflowServiceModule : AbpModule diff --git a/aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging/LINGYUN/Abp/AuditLogging/AbpAuditLoggingModule.cs b/aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging/LINGYUN/Abp/AuditLogging/AbpAuditLoggingModule.cs index e0dcf12a4..dc0e7ce71 100644 --- a/aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging/LINGYUN/Abp/AuditLogging/AbpAuditLoggingModule.cs +++ b/aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging/LINGYUN/Abp/AuditLogging/AbpAuditLoggingModule.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using System.Collections.Generic; using System.Threading; @@ -43,13 +44,16 @@ public class AbpAuditLoggingModule : AbpModule { var rootServiceProvider = context.ServiceProvider.GetRequiredService(); var options = context.ServiceProvider.GetRequiredService>(); + var logger = context.ServiceProvider.GetRequiredService>(); if (options.Value.UseAuditLogQueue) { var auditLogQueue = rootServiceProvider.GetRequiredService(); if (auditLogQueue is AuditLogQueue queue1) { + logger.LogInformation("Prepare to start the audit log queue."); await queue1.StartAsync(_cancellationTokenSource.Token); + logger.LogInformation("The audit log queue is ready."); } } @@ -58,7 +62,9 @@ public class AbpAuditLoggingModule : AbpModule var securityLogQueue = rootServiceProvider.GetRequiredService(); if (securityLogQueue is SecurityLogQueue queue2) { + logger.LogInformation("Prepare to start the security log queue."); await queue2.StartAsync(_cancellationTokenSource.Token); + logger.LogInformation("The security log queue is ready."); } } } @@ -67,13 +73,16 @@ public class AbpAuditLoggingModule : AbpModule { var rootServiceProvider = context.ServiceProvider.GetRequiredService(); var options = context.ServiceProvider.GetRequiredService>(); + var logger = context.ServiceProvider.GetRequiredService>(); if (options.Value.UseAuditLogQueue) { var auditLogQueue = rootServiceProvider.GetRequiredService(); if (auditLogQueue is AuditLogQueue queue1) { + logger.LogInformation("Prepare to stop the audit log queue."); await queue1.StopAsync(_cancellationTokenSource.Token); + logger.LogInformation("The audit log queue has been stopped."); } } @@ -82,7 +91,9 @@ public class AbpAuditLoggingModule : AbpModule var securityLogQueue = rootServiceProvider.GetRequiredService(); if (securityLogQueue is SecurityLogQueue queue2) { + logger.LogInformation("Prepare to stop the security log queue."); await queue2.StopAsync(_cancellationTokenSource.Token); + logger.LogInformation("The security log queue has been stopped."); } } diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/FodyWeavers.xml b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/FodyWeavers.xml similarity index 100% rename from aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/FodyWeavers.xml rename to aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/FodyWeavers.xml diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/FodyWeavers.xsd b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/FodyWeavers.xsd similarity index 100% rename from aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/FodyWeavers.xsd rename to aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/FodyWeavers.xsd diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN.Abp.Identity.Session.AspNetCore.csproj b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN.Abp.AspNetCore.Session.csproj similarity index 63% rename from aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN.Abp.Identity.Session.AspNetCore.csproj rename to aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN.Abp.AspNetCore.Session.csproj index b8f90ef3b..a877f48f9 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN.Abp.Identity.Session.AspNetCore.csproj +++ b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN.Abp.AspNetCore.Session.csproj @@ -5,8 +5,8 @@ net10.0 - LINGYUN.Abp.Identity.Session.AspNetCore - LINGYUN.Abp.Identity.Session.AspNetCore + LINGYUN.Abp.AspNetCore.Session + LINGYUN.Abp.AspNetCore.Session false false false @@ -18,8 +18,8 @@ - - + + diff --git a/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/AbpAspNetCoreSessionModule.cs b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/AbpAspNetCoreSessionModule.cs new file mode 100644 index 000000000..af71f16d5 --- /dev/null +++ b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/AbpAspNetCoreSessionModule.cs @@ -0,0 +1,15 @@ +using LINGYUN.Abp.Identity.Session; +using LINGYUN.Abp.IP.Location; +using Volo.Abp.AspNetCore; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.AspNetCore.Session; + +[DependsOn( + typeof(AbpIdentitySessionModule), + typeof(AbpIPLocationModule), + typeof(AbpAspNetCoreModule))] +public class AbpAspNetCoreSessionModule : AbpModule +{ + +} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpIdentitySessionAspNetCoreOptions.cs b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/AbpAspNetCoreSessionOptions.cs similarity index 53% rename from aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpIdentitySessionAspNetCoreOptions.cs rename to aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/AbpAspNetCoreSessionOptions.cs index b97781ede..1e2538c50 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpIdentitySessionAspNetCoreOptions.cs +++ b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/AbpAspNetCoreSessionOptions.cs @@ -1,12 +1,13 @@ -namespace LINGYUN.Abp.Identity.Session.AspNetCore; -public class AbpIdentitySessionAspNetCoreOptions +namespace LINGYUN.Abp.AspNetCore.Session; + +public class AbpAspNetCoreSessionOptions { /// /// 是否解析IP地理信息 /// public bool IsParseIpLocation { get; set; } - public AbpIdentitySessionAspNetCoreOptions() + public AbpAspNetCoreSessionOptions() { IsParseIpLocation = false; } diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpIdentitySessionDynamicClaimsPrincipalContributor.cs b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/AbpIdentitySessionDynamicClaimsPrincipalContributor.cs similarity index 92% rename from aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpIdentitySessionDynamicClaimsPrincipalContributor.cs rename to aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/AbpIdentitySessionDynamicClaimsPrincipalContributor.cs index 79b10be7e..d1e1bdc32 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpIdentitySessionDynamicClaimsPrincipalContributor.cs +++ b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/AbpIdentitySessionDynamicClaimsPrincipalContributor.cs @@ -1,4 +1,5 @@ -using System; +using LINGYUN.Abp.Identity.Session; +using System; using System.Linq; using System.Security.Claims; using System.Security.Principal; @@ -7,7 +8,8 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.MultiTenancy; using Volo.Abp.Security.Claims; -namespace LINGYUN.Abp.Identity.Session.AspNetCore; +namespace LINGYUN.Abp.AspNetCore.Session; + public class AbpIdentitySessionDynamicClaimsPrincipalContributor : IAbpDynamicClaimsPrincipalContributor, ITransientDependency { public async virtual Task ContributeAsync(AbpClaimsPrincipalContributorContext context) diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/HttpContextDeviceInfoProvider.cs b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/HttpContextDeviceInfoProvider.cs similarity index 94% rename from aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/HttpContextDeviceInfoProvider.cs rename to aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/HttpContextDeviceInfoProvider.cs index 1cec4be77..22bedfcbc 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/HttpContextDeviceInfoProvider.cs +++ b/aspnet-core/framework/common/LINGYUN.Abp.AspNetCore.Session/LINGYUN/Abp/AspNetCore/Session/HttpContextDeviceInfoProvider.cs @@ -1,4 +1,5 @@ -using LINGYUN.Abp.IP.Location; +using LINGYUN.Abp.Identity.Session; +using LINGYUN.Abp.IP.Location; using Microsoft.Extensions.Options; using MyCSharp.HttpUserAgentParser; using MyCSharp.HttpUserAgentParser.Providers; @@ -7,19 +8,20 @@ using System.Threading.Tasks; using Volo.Abp.AspNetCore.WebClientInfo; using Volo.Abp.DependencyInjection; -namespace LINGYUN.Abp.Identity.Session.AspNetCore; +namespace LINGYUN.Abp.AspNetCore.Session; + public class HttpContextDeviceInfoProvider : IDeviceInfoProvider, ITransientDependency { protected IIPLocationResolver IPLocationResolver { get; } protected IWebClientInfoProvider WebClientInfoProvider { get; } protected IHttpUserAgentParserProvider HttpUserAgentParser { get; } - protected AbpIdentitySessionAspNetCoreOptions Options { get; } + protected AbpAspNetCoreSessionOptions Options { get; } public HttpContextDeviceInfoProvider( IIPLocationResolver iPLocationResolver, IWebClientInfoProvider webClientInfoProvider, IHttpUserAgentParserProvider httpUserAgentParserProvider, - IOptions options) + IOptions options) { IPLocationResolver = iPLocationResolver; WebClientInfoProvider = webClientInfoProvider; @@ -103,3 +105,5 @@ public class HttpContextDeviceInfoProvider : IDeviceInfoProvider, ITransientDepe } } } + + diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/AbpAccountWebIdentityServerModule.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/AbpAccountWebIdentityServerModule.cs index 207966e60..4f88390a7 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/AbpAccountWebIdentityServerModule.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/AbpAccountWebIdentityServerModule.cs @@ -1,5 +1,12 @@ -using Microsoft.Extensions.DependencyInjection; +using IdentityServer4.Validation; +using LINGYUN.Abp.Account.Web.IdentityServer.Handlers; +using LINGYUN.Abp.Account.Web.IdentityServer.Services; +using Microsoft.AspNetCore.Authentication; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Volo.Abp.IdentityServer; using Volo.Abp.Modularity; +using Volo.Abp.Security.Claims; using Volo.Abp.VirtualFileSystem; using VoloAbpAccountWebIdentityServerModule = Volo.Abp.Account.Web.AbpAccountWebIdentityServerModule; @@ -24,5 +31,20 @@ public class AbpAccountWebIdentityServerModule : AbpModule { options.FileSets.AddEmbedded(); }); + + //Configure(options => + //{ + // options.EventServiceHandlers.Add(); + //}); + + Configure(options => + { + options.RequestedClaims.Add(AbpClaimTypes.SessionId); + }); + + context.Services.Replace( + ServiceDescriptor.Transient()); + context.Services.Replace( + ServiceDescriptor.Transient()); } } diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Handlers/AbpIdentitySessionEventServiceHandler.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Handlers/AbpIdentitySessionEventServiceHandler.cs new file mode 100644 index 000000000..92d107ade --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Handlers/AbpIdentitySessionEventServiceHandler.cs @@ -0,0 +1,102 @@ +//using IdentityServer4.Events; +//using LINGYUN.Abp.Identity.Session; +//using System; +//using System.Security.Claims; +//using System.Threading.Tasks; +//using Volo.Abp.DependencyInjection; +//using Volo.Abp.MultiTenancy; +//using Volo.Abp.Security.Claims; +//using Volo.Abp.Uow; + +//namespace LINGYUN.Abp.IdentityServer.Session; +///// +///// 持久化用户会话 +///// +//public class AbpIdentitySessionEventServiceHandler : IAbpIdentityServerEventServiceHandler, ITransientDependency +//{ +// protected ICurrentTenant CurrentTenant { get; } +// protected ISessionInfoProvider SessionInfoProvider { get; } +// protected IIdentitySessionManager IdentitySessionManager { get; } +// protected ICurrentPrincipalAccessor CurrentPrincipalAccessor { get; } + +// public AbpIdentitySessionEventServiceHandler( +// ICurrentTenant currentTenant, +// ISessionInfoProvider sessionInfoProvider, +// IIdentitySessionManager identitySessionManager, +// ICurrentPrincipalAccessor currentPrincipalAccessor) +// { +// CurrentTenant = currentTenant; +// SessionInfoProvider = sessionInfoProvider; +// IdentitySessionManager = identitySessionManager; +// CurrentPrincipalAccessor = currentPrincipalAccessor; +// } + +// public virtual bool CanRaiseEventType(EventTypes evtType) +// { +// return evtType == EventTypes.Success; +// } + +// [UnitOfWork] +// public virtual Task RaiseAsync(Event evt) +// { +// if (evt is UserLoginSuccessEvent loginEvent) +// { +// // 用户登录事件 +// return RaiseUserLoginSuccessEventAsync(loginEvent); +// } +// if (evt is UserLogoutSuccessEvent logoutEvent) +// { +// // 用户退出事件 +// return RaiseUserLogoutSuccessEventAsync(logoutEvent); +// } +// if (evt is TokenRevokedSuccessEvent revokeEvent) +// { +// // 撤销令牌事件 +// return RaiseTokenRevokedSuccessEventAsync(revokeEvent); +// } +// return Task.CompletedTask; +// } + +// protected async virtual Task RaiseUserLoginSuccessEventAsync(UserLoginSuccessEvent loginEvent) +// { +// var subjectId = loginEvent.SubjectId; +// var sessionId = SessionInfoProvider.SessionId; +// if (!sessionId.IsNullOrWhiteSpace() && +// Guid.TryParse(subjectId, out var userId)) +// { +// var claimsIdentity = new ClaimsIdentity(); +// claimsIdentity.AddClaim(new Claim(AbpClaimTypes.UserId, userId.ToString())); +// claimsIdentity.AddClaim(new Claim(AbpClaimTypes.SessionId, sessionId)); +// if (!loginEvent.ClientId.IsNullOrWhiteSpace()) +// { +// claimsIdentity.AddClaim(new Claim(AbpClaimTypes.ClientId, loginEvent.ClientId)); +// } +// if (CurrentTenant.IsAvailable) +// { +// claimsIdentity.AddClaim(new Claim(AbpClaimTypes.TenantId, CurrentTenant.Id!.Value.ToString())); +// } +// var claimsPrincipal = new ClaimsPrincipal(claimsIdentity); +// using (CurrentPrincipalAccessor.Change(claimsPrincipal)) +// { +// await IdentitySessionManager.SaveSessionAsync(claimsPrincipal); +// } +// } +// } +// protected async virtual Task RaiseUserLogoutSuccessEventAsync(UserLogoutSuccessEvent logoutEvent) +// { +// var sessionId = SessionInfoProvider.SessionId; +// if (!sessionId.IsNullOrWhiteSpace()) +// { +// await IdentitySessionManager.RevokeSessionAsync(sessionId); +// } +// } + +// protected async virtual Task RaiseTokenRevokedSuccessEventAsync(TokenRevokedSuccessEvent revokeEvent) +// { +// var sessionId = SessionInfoProvider.SessionId; +// if (!sessionId.IsNullOrWhiteSpace()) +// { +// await IdentitySessionManager.RevokeSessionAsync(sessionId); +// } +// } +//} diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/AbpIdentitySessionUserInfoRequestValidator.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Handlers/AbpIdentitySessionUserInfoRequestValidator.cs similarity index 97% rename from aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/AbpIdentitySessionUserInfoRequestValidator.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Handlers/AbpIdentitySessionUserInfoRequestValidator.cs index c593536fd..665d1c040 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/AbpIdentitySessionUserInfoRequestValidator.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Handlers/AbpIdentitySessionUserInfoRequestValidator.cs @@ -1,4 +1,4 @@ -using IdentityModel; +using Duende.IdentityModel; using IdentityServer4; using IdentityServer4.Extensions; using IdentityServer4.Models; @@ -6,11 +6,12 @@ using IdentityServer4.Services; using IdentityServer4.Validation; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; -using System; using System.Linq; using System.Threading.Tasks; -namespace LINGYUN.Abp.IdentityServer.Session; +namespace LINGYUN.Abp.Account.Web.IdentityServer.Handlers; + + public class AbpIdentitySessionUserInfoRequestValidator : IUserInfoRequestValidator { private readonly IHttpContextAccessor _httpContextAccessor; @@ -104,3 +105,4 @@ public class AbpIdentitySessionUserInfoRequestValidator : IUserInfoRequestValida } } + diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/Constants.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Handlers/Constants.cs similarity index 95% rename from aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/Constants.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Handlers/Constants.cs index 325b0b9ce..20a99cff3 100644 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/Constants.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Handlers/Constants.cs @@ -1,7 +1,7 @@ using IdentityModel; using System.Collections.Generic; -namespace LINGYUN.Abp.IdentityServer.Session; +namespace LINGYUN.Abp.Account.Web.IdentityServer.Handlers; internal static class Constants { public static Dictionary ProtectedResourceErrorStatusCodes = new Dictionary diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Services/IdentityServerSessionAuthenticationService.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Services/IdentityServerSessionAuthenticationService.cs new file mode 100644 index 000000000..471dab4e9 --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/Services/IdentityServerSessionAuthenticationService.cs @@ -0,0 +1,114 @@ +using Duende.IdentityModel; +using LINGYUN.Abp.Identity.Session; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.WebUtilities; +using Microsoft.Extensions.Options; +using System; +using System.Linq; +using System.Security.Claims; +using System.Security.Principal; +using System.Threading.Tasks; +using Volo.Abp.Security.Claims; + +namespace LINGYUN.Abp.Account.Web.IdentityServer.Services; + +public class IdentityServerSessionAuthenticationService : AuthenticationService +{ + protected IIdentitySessionManager IdentitySessionManager { get; } + + public IdentityServerSessionAuthenticationService( + IAuthenticationSchemeProvider schemes, + IAuthenticationHandlerProvider handlers, + IClaimsTransformation transform, + IOptions options, + IIdentitySessionManager identitySessionManager) : base(schemes, handlers, transform, options) + { + IdentitySessionManager = identitySessionManager; + } + + public async override Task SignInAsync(HttpContext context, string? scheme, ClaimsPrincipal principal, AuthenticationProperties? properties) + { + var claimsIdentity = principal.Identities.FirstOrDefault(); + if (claimsIdentity == null || !claimsIdentity.FindSessionId().IsNullOrWhiteSpace()) + { + await base.SignInAsync(context, scheme, principal, properties); + return; + } + + claimsIdentity.AddClaim(new Claim(AbpClaimTypes.SessionId, Guid.NewGuid().ToString())); + + var clientId = principal.FindClientId(); + if (clientId.IsNullOrWhiteSpace()) + { + // 从授权回调中获取客户端Id + clientId = FindClientId(context); + } + + await base.SignInAsync(context, scheme, principal, properties); + + await IdentitySessionManager.SaveSessionAsync(clientId, principal, context.RequestAborted); + } + + public async override Task SignOutAsync(HttpContext context, string? scheme, AuthenticationProperties? properties) + { + var sessionId = context.User?.FindSessionId(); + if (!sessionId.IsNullOrWhiteSpace()) + { + // Revoke the user session. + await IdentitySessionManager.RevokeSessionAsync(sessionId, context.RequestAborted); + } + + await base.SignOutAsync(context, scheme, properties); + } + + private static string? FindClientId(HttpContext context) + { + if (context.Request.Query.TryGetValue("ReturnUrl", out var queryReturnUrls)) + { + var clientId = GetQueryValue(queryReturnUrls.FirstOrDefault()); + if (!clientId.IsNullOrWhiteSpace()) + { + return clientId; + } + } + + if (context.Request.Form.TryGetValue("ReturnUrl", out var formReturnUrls)) + { + var clientId = GetQueryValue(formReturnUrls.FirstOrDefault()); + if (!clientId.IsNullOrWhiteSpace()) + { + return clientId; + } + } + + if (context.Request.Query.TryGetValue(JwtClaimTypes.ClientId, out var queryClientIds)) + { + return queryClientIds.FirstOrDefault(); + } + + if (context.Request.Form.TryGetValue(JwtClaimTypes.ClientId, out var formClientIds)) + { + return formClientIds.FirstOrDefault(); + } + + return null; + } + + private static string? GetQueryValue(string? returnUrls) + { + if (string.IsNullOrWhiteSpace(returnUrls)) + { + return null; + } + + if (returnUrls.Contains('?')) + { + returnUrls = returnUrls.Split('?')[1]; + } + + var parameters = QueryHelpers.ParseQuery(returnUrls); + + return parameters.TryGetValue(JwtClaimTypes.ClientId, out var clientId) ? clientId.ToString() : null; + } +} diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/System/StringsExtensions.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/System/StringsExtensions.cs similarity index 100% rename from aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/System/StringsExtensions.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Web.IdentityServer/System/StringsExtensions.cs diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/AbpAccountWebOpenIddictModule.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/AbpAccountWebOpenIddictModule.cs index d175fa15c..1999aa401 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/AbpAccountWebOpenIddictModule.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/AbpAccountWebOpenIddictModule.cs @@ -1,7 +1,12 @@ -using LINGYUN.Abp.Account.Web.OpenIddict.Pages.Account; +using LINGYUN.Abp.Account.Web.OpenIddict.Handlers; +using LINGYUN.Abp.Account.Web.OpenIddict.Pages.Account; +using LINGYUN.Abp.Account.Web.OpenIddict.Services; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using OpenIddict.Validation; using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.Localization; @@ -28,6 +33,13 @@ public class AbpAccountWebOpenIddictModule : AbpModule { mvcBuilder.AddApplicationPartIfNotExists(typeof(AbpAccountWebOpenIddictModule).Assembly); }); + + PreConfigure(builder => + { + builder.AddEventHandler(ProcessSignOutIdentitySession.Descriptor); + builder.AddEventHandler(RevocationIdentitySession.Descriptor); + builder.AddEventHandler(ServerValidationTokenCheckIdentitySession.Descriptor); + }); } public override void ConfigureServices(ServiceConfigurationContext context) @@ -68,5 +80,15 @@ public class AbpAccountWebOpenIddictModule : AbpModule bundle.AddFiles("/css/select-account.css"); }); }); + + context.Services.Add(ValidationTokenCheckIdentitySession.Descriptor.ServiceDescriptor); + + Configure(options => + { + options.Handlers.Add(ValidationTokenCheckIdentitySession.Descriptor); + }); + + context.Services.Replace( + ServiceDescriptor.Transient()); } } diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Controllers/AuthorizeController.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Controllers/AuthorizeController.cs index d97be5a5e..6baf3bc36 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Controllers/AuthorizeController.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Controllers/AuthorizeController.cs @@ -15,6 +15,7 @@ using System.Collections.Immutable; using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Security.Claims; +using System.Security.Principal; using System.Text.Encodings.Web; using System.Threading.Tasks; using Volo.Abp.AspNetCore.Security; @@ -185,6 +186,14 @@ public class AuthorizeController : Volo.Abp.OpenIddict.Controllers.AuthorizeCont principal.Identities.FirstOrDefault()?.AddClaim(claim); } + // 需透传会话Id,避免创建多个会话 + var claimsIdentity = principal.Identities.FirstOrDefault(); + var sessionId = result.Principal.FindSessionId(); + if (!sessionId.IsNullOrWhiteSpace()) + { + claimsIdentity?.AddClaim(new Claim(AbpClaimTypes.SessionId, sessionId)); + } + // Note: in this sample, the granted scopes match the requested scope // but you may want to allow the user to uncheck specific scopes. // For that, simply restrict the list of scopes before calling SetScopes. @@ -287,10 +296,21 @@ public class AuthorizeController : Volo.Abp.OpenIddict.Controllers.AuthorizeCont } var result = await HttpContext.AuthenticateAsync(IdentityConstants.ApplicationScheme); - if (result.Succeeded && result.Properties != null && result.Properties.IsPersistent) + if (result.Succeeded) { - var claim = new Claim(AbpClaimTypes.RememberMe, true.ToString()).SetDestinations(OpenIddictConstants.Destinations.AccessToken); - principal.Identities.FirstOrDefault()?.AddClaim(claim); + if (result.Properties != null && result.Properties.IsPersistent) + { + var claim = new Claim(AbpClaimTypes.RememberMe, true.ToString()).SetDestinations(OpenIddictConstants.Destinations.AccessToken); + principal.Identities.FirstOrDefault()?.AddClaim(claim); + } + + // 需透传会话Id,避免创建多个会话 + var claimsIdentity = principal.Identities.FirstOrDefault(); + var sessionId = result.Principal.FindSessionId(); + if (!sessionId.IsNullOrWhiteSpace()) + { + claimsIdentity?.AddClaim(new Claim(AbpClaimTypes.SessionId, sessionId)); + } } var scopes = Request.Form["selected_scopes"].ToString()?.Split(" ").ToImmutableArray() ?? []; if (scopes.IsNullOrEmpty()) @@ -313,7 +333,7 @@ public class AuthorizeController : Volo.Abp.OpenIddict.Controllers.AuthorizeCont subject: await UserManager.GetUserIdAsync(user), client: (await ApplicationManager.GetIdAsync(application))!, type: OpenIddictConstants.AuthorizationTypes.Permanent, - scopes: principal.GetScopes()); + scopes: scopes); } principal.SetAuthorizationId(await AuthorizationManager.GetIdAsync(authorization)); diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ProcessSignOutIdentitySession.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers/ProcessSignOutIdentitySession.cs similarity index 81% rename from aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ProcessSignOutIdentitySession.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers/ProcessSignOutIdentitySession.cs index 44cf385a3..c7e9d5985 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ProcessSignOutIdentitySession.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers/ProcessSignOutIdentitySession.cs @@ -1,15 +1,18 @@ using LINGYUN.Abp.Identity.Session; using OpenIddict.Server; using System; +using System.Security.Principal; using System.Threading.Tasks; +using Volo.Abp.Users; + +namespace LINGYUN.Abp.Account.Web.OpenIddict.Handlers; -namespace LINGYUN.Abp.OpenIddict.AspNetCore.Session; /// /// 用户退出登录终止会话 /// public class ProcessSignOutIdentitySession : IOpenIddictServerHandler { - protected ISessionInfoProvider SessionInfoProvider { get; } + protected ICurrentUser CurrentUser { get; } protected IIdentitySessionManager IdentitySessionManager { get; } public static OpenIddictServerHandlerDescriptor Descriptor { get; } @@ -21,19 +24,20 @@ public class ProcessSignOutIdentitySession : IOpenIddictServerHandler /// 令牌撤销终止用户会话 /// diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ServerValidationTokenCheckIdentitySession.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers/ServerValidationTokenCheckIdentitySession.cs similarity index 72% rename from aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ServerValidationTokenCheckIdentitySession.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers/ServerValidationTokenCheckIdentitySession.cs index ae5eb8090..2577ff084 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ServerValidationTokenCheckIdentitySession.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers/ServerValidationTokenCheckIdentitySession.cs @@ -1,20 +1,20 @@ using LINGYUN.Abp.Identity.Session; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; using OpenIddict.Server; +using System; using System.Security.Principal; using System.Threading.Tasks; using Volo.Abp.MultiTenancy; using static OpenIddict.Abstractions.OpenIddictConstants; -namespace LINGYUN.Abp.OpenIddict.AspNetCore.Session; +namespace LINGYUN.Abp.Account.Web.OpenIddict.Handlers; + public class ServerValidationTokenCheckIdentitySession : IOpenIddictServerHandler { public ILogger Logger { protected get; set; } protected ICurrentTenant CurrentTenant { get; } protected IIdentitySessionChecker IdentitySessionChecker { get; } - protected AbpOpenIddictAspNetCoreSessionOptions AbpOpenIddictAspNetCoreSessionOptions { get; } public static OpenIddictServerHandlerDescriptor Descriptor { get; } = OpenIddictServerHandlerDescriptor.CreateBuilder() @@ -23,30 +23,28 @@ public class ServerValidationTokenCheckIdentitySession : IOpenIddictServerHandle .SetType(OpenIddictServerHandlerType.Custom).Build(); public ServerValidationTokenCheckIdentitySession( - ICurrentTenant currentTenant, - IIdentitySessionChecker identitySessionChecker, - IOptions abpOpenIddictAspNetCoreSessionOptions) + ICurrentTenant currentTenant, + IIdentitySessionChecker identitySessionChecker) { CurrentTenant = currentTenant; IdentitySessionChecker = identitySessionChecker; - AbpOpenIddictAspNetCoreSessionOptions = abpOpenIddictAspNetCoreSessionOptions.Value; Logger = NullLogger.Instance; } public async virtual ValueTask HandleAsync(OpenIddictServerEvents.ValidateTokenContext context) { - Logger.LogInformation("Server Validate Token: {endpointType} - {requestUri}", context.EndpointType, context.RequestUri); + Logger.LogDebug("Server Validate Token: {endpointType} - {requestUri}", context.EndpointType, context.RequestUri); - if (!AbpOpenIddictAspNetCoreSessionOptions.ValidationSessionEndpointTypes.Contains(context.EndpointType)) + if (context.Principal == null || context.Principal.Identity?.IsAuthenticated == false) { - Logger.LogDebug("Endpoint '{endpointType}' is not in validation whitelist, skipping session validation.", context.EndpointType); + Logger.LogWarning("Principal is null or not authenticated for endpoint '{endpointType}', skipping session validation.", context.EndpointType); return; } - - if (context.Principal == null || context.Principal.Identity?.IsAuthenticated == false) + var sessionId = context.Principal?.FindSessionId(); + if (sessionId.IsNullOrWhiteSpace()) { - Logger.LogWarning("Principal is null or not authenticated for endpoint '{endpointType}', skipping session validation.", context.EndpointType); + Logger.LogWarning("SessionId is null for endpoint '{endpointType}', skipping session validation.", context.EndpointType); return; } @@ -63,3 +61,4 @@ public class ServerValidationTokenCheckIdentitySession : IOpenIddictServerHandle } } } + diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ValidationTokenCheckIdentitySession.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers/ValidationTokenCheckIdentitySession.cs similarity index 97% rename from aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ValidationTokenCheckIdentitySession.cs rename to aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers/ValidationTokenCheckIdentitySession.cs index 26f734379..8b127f26d 100644 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ValidationTokenCheckIdentitySession.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Handlers/ValidationTokenCheckIdentitySession.cs @@ -7,7 +7,8 @@ using System.Threading.Tasks; using Volo.Abp.MultiTenancy; using static OpenIddict.Abstractions.OpenIddictConstants; -namespace LINGYUN.Abp.OpenIddict.AspNetCore.Session; +namespace LINGYUN.Abp.Account.Web.OpenIddict.Handlers; + public class ValidationTokenCheckIdentitySession : IOpenIddictValidationHandler { public ILogger Logger { protected get; set; } @@ -48,3 +49,4 @@ public class ValidationTokenCheckIdentitySession : IOpenIddictValidationHandler< } } } + diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Services/OpenIddictSessionAuthenticationService.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Services/OpenIddictSessionAuthenticationService.cs new file mode 100644 index 000000000..73cbf4988 --- /dev/null +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Web.OpenIddict/Services/OpenIddictSessionAuthenticationService.cs @@ -0,0 +1,114 @@ +using Duende.IdentityModel; +using LINGYUN.Abp.Identity.Session; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.WebUtilities; +using Microsoft.Extensions.Options; +using System; +using System.Linq; +using System.Security.Claims; +using System.Security.Principal; +using System.Threading.Tasks; +using Volo.Abp.Security.Claims; + +namespace LINGYUN.Abp.Account.Web.OpenIddict.Services; + +public class OpenIddictSessionAuthenticationService : AuthenticationService +{ + protected IIdentitySessionManager IdentitySessionManager { get; } + + public OpenIddictSessionAuthenticationService( + IAuthenticationSchemeProvider schemes, + IAuthenticationHandlerProvider handlers, + IClaimsTransformation transform, + IOptions options, + IIdentitySessionManager identitySessionManager) : base(schemes, handlers, transform, options) + { + IdentitySessionManager = identitySessionManager; + } + + public async override Task SignInAsync(HttpContext context, string? scheme, ClaimsPrincipal principal, AuthenticationProperties? properties) + { + var claimsIdentity = principal.Identities.FirstOrDefault(); + if (claimsIdentity == null || !claimsIdentity.FindSessionId().IsNullOrWhiteSpace()) + { + await base.SignInAsync(context, scheme, principal, properties); + return; + } + + claimsIdentity.AddClaim(new Claim(AbpClaimTypes.SessionId, Guid.NewGuid().ToString())); + + var clientId = principal.FindClientId(); + if (clientId.IsNullOrWhiteSpace()) + { + // 从授权回调中获取客户端Id + clientId = FindClientId(context); + } + + await base.SignInAsync(context, scheme, principal, properties); + + await IdentitySessionManager.SaveSessionAsync(clientId, principal, context.RequestAborted); + } + + public async override Task SignOutAsync(HttpContext context, string? scheme, AuthenticationProperties? properties) + { + var sessionId = context.User?.FindSessionId(); + if (!sessionId.IsNullOrWhiteSpace()) + { + // Revoke the user session. + await IdentitySessionManager.RevokeSessionAsync(sessionId, context.RequestAborted); + } + + await base.SignOutAsync(context, scheme, properties); + } + + private static string? FindClientId(HttpContext context) + { + if (context.Request.Query.TryGetValue("ReturnUrl", out var queryReturnUrls)) + { + var clientId = GetQueryValue(queryReturnUrls.FirstOrDefault()); + if (!clientId.IsNullOrWhiteSpace()) + { + return clientId; + } + } + + if (context.Request.Form.TryGetValue("ReturnUrl", out var formReturnUrls)) + { + var clientId = GetQueryValue(formReturnUrls.FirstOrDefault()); + if (!clientId.IsNullOrWhiteSpace()) + { + return clientId; + } + } + + if (context.Request.Query.TryGetValue(JwtClaimTypes.ClientId, out var queryClientIds)) + { + return queryClientIds.FirstOrDefault(); + } + + if (context.Request.Form.TryGetValue(JwtClaimTypes.ClientId, out var formClientIds)) + { + return formClientIds.FirstOrDefault(); + } + + return null; + } + + private static string? GetQueryValue(string? returnUrls) + { + if (string.IsNullOrWhiteSpace(returnUrls)) + { + return null; + } + + if (returnUrls.Contains('?')) + { + returnUrls = returnUrls.Split('?')[1]; + } + + var parameters = QueryHelpers.ParseQuery(returnUrls); + + return parameters.TryGetValue(JwtClaimTypes.ClientId, out var clientId) ? clientId.ToString() : null; + } +} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/LINGYUN.Abp.Identity.AspNetCore.Session.csproj b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/LINGYUN.Abp.Identity.AspNetCore.Session.csproj deleted file mode 100644 index 9741c7a3f..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/LINGYUN.Abp.Identity.AspNetCore.Session.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - net10.0 - LINGYUN.Abp.Identity.AspNetCore.Session - LINGYUN.Abp.Identity.AspNetCore.Session - false - false - false - - - - - - - - - - - - diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/LINGYUN/Abp/Identity/AspNetCore/Session/AbpIdentityAspNetCoreSessionModule.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/LINGYUN/Abp/Identity/AspNetCore/Session/AbpIdentityAspNetCoreSessionModule.cs deleted file mode 100644 index e420791f6..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/LINGYUN/Abp/Identity/AspNetCore/Session/AbpIdentityAspNetCoreSessionModule.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Identity; -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Identity.AspNetCore; -using Volo.Abp.Modularity; - -namespace LINGYUN.Abp.Identity.AspNetCore.Session; - -[DependsOn( - typeof(AbpIdentityAspNetCoreModule), - typeof(AbpIdentityDomainModule))] -public class AbpIdentityAspNetCoreSessionModule : AbpModule -{ - public override void PreConfigureServices(ServiceConfigurationContext context) - { - PreConfigure(builder => - { - // builder.AddSignInManager(); - }); - } - - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddTransient(); - } -} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/LINGYUN/Abp/Identity/AspNetCore/Session/AbpIdentitySessionAuthenticationService.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/LINGYUN/Abp/Identity/AspNetCore/Session/AbpIdentitySessionAuthenticationService.cs deleted file mode 100644 index 3c85e0feb..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/LINGYUN/Abp/Identity/AspNetCore/Session/AbpIdentitySessionAuthenticationService.cs +++ /dev/null @@ -1,58 +0,0 @@ -using LINGYUN.Abp.Identity.Session; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Options; -using System; -using System.Security.Claims; -using System.Security.Principal; -using System.Threading.Tasks; - -namespace LINGYUN.Abp.Identity.AspNetCore.Session; - -public class AbpIdentitySessionAuthenticationService : AuthenticationService -{ - protected IdentitySessionSignInOptions SessionSignInOptions { get; } - protected IIdentitySessionManager IdentitySessionManager { get; } - - public AbpIdentitySessionAuthenticationService( - IAuthenticationSchemeProvider schemes, - IAuthenticationHandlerProvider handlers, - IClaimsTransformation transform, - IOptions options, - IIdentitySessionManager identitySessionManager, - IOptions sessionSignInOptions) : base(schemes, handlers, transform, options) - { - SessionSignInOptions = sessionSignInOptions.Value; - IdentitySessionManager = identitySessionManager; - } - - public async override Task SignInAsync(HttpContext context, string? scheme, ClaimsPrincipal principal, AuthenticationProperties? properties) - { - await base.SignInAsync(context, scheme, principal, properties); - - if (SessionSignInOptions.SignInSessionEnabled && - !scheme.IsNullOrWhiteSpace() && - SessionSignInOptions.AuthenticationSchemes.Contains(scheme)) - { - // Save the user session. - await IdentitySessionManager.SaveSessionAsync(principal); - } - } - - public async override Task SignOutAsync(HttpContext context, string? scheme, AuthenticationProperties? properties) - { - if (SessionSignInOptions.SignOutSessionEnabled && - !scheme.IsNullOrWhiteSpace() && - SessionSignInOptions.AuthenticationSchemes.Contains(scheme)) - { - var sessionId = context.User?.FindSessionId(); - if (!sessionId.IsNullOrWhiteSpace()) - { - // Revoke the user session. - await IdentitySessionManager.RevokeSessionAsync(sessionId); - } - } - - await base.SignOutAsync(context, scheme, properties); - } -} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/README.EN.md b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/README.EN.md deleted file mode 100644 index 244f671ab..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/README.EN.md +++ /dev/null @@ -1,67 +0,0 @@ -# LINGYUN.Abp.Identity.AspNetCore.Session - -User session login extension module, mainly handling login/logout events provided by *AspNetCore.Identity* to manage sessions. - -Due to module responsibility separation principle, please do not confuse with *LINGYUN.Abp.Identity.Session.AspNetCore* module. - -## Configuration Usage - -```csharp -[DependsOn(typeof(AbpIdentityAspNetCoreSessionModule))] -public class YouProjectModule : AbpModule -{ - // other -} -``` - -## Features - -* Extends AbpIdentityAspNetCoreModule module -* Provides session management functionality in AspNetCore environment -* Custom authentication service implementation -* Integrates with AspNetCore.Identity login/logout events - -## Service Implementation - -* AbpIdentitySessionAuthenticationService - Custom authentication service - * Handles user login/logout events - * Manages user session state - * Integrates with Identity session system - -## Basic Usage - -1. Configure authentication service -```csharp -public override void ConfigureServices(ServiceConfigurationContext context) -{ - context.Services.AddTransient(); -} -``` - -2. Use authentication service -```csharp -public class YourService -{ - private readonly IAuthenticationService _authenticationService; - - public YourService(IAuthenticationService authenticationService) - { - _authenticationService = authenticationService; - } - - public async Task SignInAsync(HttpContext context, string scheme, ClaimsPrincipal principal, AuthenticationProperties properties) - { - await _authenticationService.SignInAsync(context, scheme, principal, properties); - } - - public async Task SignOutAsync(HttpContext context, string scheme, AuthenticationProperties properties) - { - await _authenticationService.SignOutAsync(context, scheme, properties); - } -} -``` - -## More Information - -* [ABP Identity Documentation](https://docs.abp.io/en/abp/latest/Identity) -* [ASP.NET Core Identity Documentation](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity) diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/README.md b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/README.md deleted file mode 100644 index 580848c65..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.AspNetCore.Session/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# LINGYUN.Abp.Identity.AspNetCore.Session - -用户会话登录扩展模块,主要处理 *AspNetCore.Identity* 提供的登录/登出事件来管理会话 - -出于模块职责分离原则, 请勿与 *LINGYUN.Abp.Identity.Session.AspNetCore* 模块混淆 - -## 配置使用 - -```csharp -[DependsOn(typeof(AbpIdentityAspNetCoreSessionModule))] -public class YouProjectModule : AbpModule -{ - // other -} -``` - -## 功能特性 - -* 扩展AbpIdentityAspNetCoreModule模块 -* 提供AspNetCore环境下的会话管理功能 -* 自定义身份认证服务实现 -* 集成AspNetCore.Identity的登录/登出事件 - -## 服务实现 - -* AbpIdentitySessionAuthenticationService - 自定义身份认证服务 - * 处理用户登录/登出事件 - * 管理用户会话状态 - * 与Identity会话系统集成 - -## 基本用法 - -1. 配置身份认证服务 -```csharp -public override void ConfigureServices(ServiceConfigurationContext context) -{ - context.Services.AddTransient(); -} -``` - -2. 使用身份认证服务 -```csharp -public class YourService -{ - private readonly IAuthenticationService _authenticationService; - - public YourService(IAuthenticationService authenticationService) - { - _authenticationService = authenticationService; - } - - public async Task SignInAsync(HttpContext context, string scheme, ClaimsPrincipal principal, AuthenticationProperties properties) - { - await _authenticationService.SignInAsync(context, scheme, principal, properties); - } - - public async Task SignOutAsync(HttpContext context, string scheme, AuthenticationProperties properties) - { - await _authenticationService.SignOutAsync(context, scheme, properties); - } -} -``` - -## 更多信息 - -* [ABP身份认证文档](https://docs.abp.io/en/abp/latest/Identity) -* [ASP.NET Core Identity文档](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity) diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IIdentitySessionManager.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IIdentitySessionManager.cs index 0229125b0..6c10acd19 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IIdentitySessionManager.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IIdentitySessionManager.cs @@ -18,6 +18,17 @@ public interface IIdentitySessionManager ClaimsPrincipal claimsPrincipal, CancellationToken cancellationToken = default); /// + /// 保存会话 + /// + /// 客户端Id + /// 用户身份主体 + /// + /// + Task SaveSessionAsync( + string? clientId, + ClaimsPrincipal claimsPrincipal, + CancellationToken cancellationToken = default); + /// /// 撤销用户会话 /// /// 会话id diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionClaimsPrincipalContributor.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionClaimsPrincipalContributor.cs deleted file mode 100644 index 840a864dc..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionClaimsPrincipalContributor.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Linq; -using System.Security.Claims; -using System.Security.Principal; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Security.Claims; - -namespace LINGYUN.Abp.Identity.Session.AspNetCore; -public class IdentitySessionClaimsPrincipalContributor : IAbpClaimsPrincipalContributor, ITransientDependency -{ - public virtual Task ContributeAsync(AbpClaimsPrincipalContributorContext context) - { - var claimsIdentity = context.ClaimsPrincipal.Identities.First(); - if (claimsIdentity.HasClaim(x => x.Type == AbpClaimTypes.SessionId)) - { - return Task.CompletedTask; - } - var sessionId = claimsIdentity.FindSessionId(); - if (!sessionId.IsNullOrWhiteSpace()) - { - claimsIdentity.AddOrReplace(new Claim(AbpClaimTypes.SessionId, sessionId)); - context.ClaimsPrincipal.AddIdentityIfNotContains(claimsIdentity); - return Task.CompletedTask; - } - - var userId = claimsIdentity.FindUserId(); - if (userId.HasValue) - { - var sessionInfoProvider = context.GetRequiredService(); - sessionId = sessionInfoProvider.SessionId ?? Guid.NewGuid().ToString("N"); - - claimsIdentity.AddOrReplace(new Claim(AbpClaimTypes.SessionId, sessionId)); - context.ClaimsPrincipal.AddIdentityIfNotContains(claimsIdentity); - } - return Task.CompletedTask; - } -} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionManager.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionManager.cs index 9c2c1f0b6..0db610ff1 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionManager.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionManager.cs @@ -34,6 +34,17 @@ public class IdentitySessionManager : DomainService, IIdentitySessionManager public async virtual Task SaveSessionAsync( ClaimsPrincipal claimsPrincipal, CancellationToken cancellationToken = default) + { + var clientId = claimsPrincipal.FindClientId(); + + await SaveSessionAsync(clientId, claimsPrincipal, cancellationToken); + } + + [DisableAuditing] + public async virtual Task SaveSessionAsync( + string? clientId, + ClaimsPrincipal claimsPrincipal, + CancellationToken cancellationToken = default) { if (claimsPrincipal != null) { @@ -59,9 +70,7 @@ public class IdentitySessionManager : DomainService, IIdentitySessionManager var clientIpAddress = deviceInfo.ClientIpAddress; var userName = claimsPrincipal.FindFirstValue(AbpClaimTypes.UserName); - var clientId = claimsPrincipal.FindClientId(); - - Logger.LogDebug($"Save user session for user: {userId}, session: {sessionId}"); + Logger.LogDebug("Save user session for user: {userId}, session: {sessionId}", userId, sessionId); await IdentitySessionStore.CreateAsync( sessionId, @@ -77,7 +86,7 @@ public class IdentitySessionManager : DomainService, IIdentitySessionManager tenantId, cancellationToken); - Logger.LogDebug($"Remove dynamic claims cache for user: {userId}"); + Logger.LogDebug("Remove dynamic claims cache for user: {userId}", userId); await IdentityDynamicClaimsPrincipalContributorCache.ClearAsync(userId.Value, tenantId); @@ -102,7 +111,7 @@ public class IdentitySessionManager : DomainService, IIdentitySessionManager string sessionId, CancellationToken cancellationToken = default) { - Logger.LogDebug($"Revoke user session for: {sessionId}"); + Logger.LogDebug("Revoke user session for: {sessionId}", sessionId); await IdentitySessionStore.RevokeAsync(sessionId, cancellationToken: cancellationToken); } } diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionSignInOptions.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionSignInOptions.cs deleted file mode 100644 index a8b84fca1..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionSignInOptions.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Collections.Generic; - -namespace LINGYUN.Abp.Identity.Session; -/// -/// 用于会话管理的配置 -/// -public class IdentitySessionSignInOptions -{ - /// - /// 用于处理的身份认证方案 - /// - public List AuthenticationSchemes { get; set; } - /// - /// 是否启用SignInManager登录会话 - /// 默认: false - /// - public bool SignInSessionEnabled { get; set; } - /// - /// 是否启用SignInManager登出会话 - /// 默认: false - /// - public bool SignOutSessionEnabled { get; set; } - - public IdentitySessionSignInOptions() - { - AuthenticationSchemes = new List - { - "Identity.Application" - }; - } -} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/FodyWeavers.xml b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/FodyWeavers.xml deleted file mode 100644 index 1715698cc..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/FodyWeavers.xsd b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/FodyWeavers.xsd deleted file mode 100644 index 3f3946e28..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/FodyWeavers.xsd +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. - - - - - A comma-separated list of error codes that can be safely ignored in assembly verification. - - - - - 'false' to turn off automatic generation of the XML Schema file. - - - - - \ No newline at end of file diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpIdentitySessionAspNetCoreModule.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpIdentitySessionAspNetCoreModule.cs deleted file mode 100644 index 7975a5165..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpIdentitySessionAspNetCoreModule.cs +++ /dev/null @@ -1,12 +0,0 @@ -using LINGYUN.Abp.IP.Location; -using Volo.Abp.AspNetCore; -using Volo.Abp.Modularity; - -namespace LINGYUN.Abp.Identity.Session.AspNetCore; - -[DependsOn(typeof(AbpAspNetCoreModule))] -[DependsOn(typeof(AbpIPLocationModule))] -[DependsOn(typeof(AbpIdentitySessionModule))] -public class AbpIdentitySessionAspNetCoreModule : AbpModule -{ -} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpSessionApplicationBuilderExtensions.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpSessionApplicationBuilderExtensions.cs deleted file mode 100644 index 01746cc08..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpSessionApplicationBuilderExtensions.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.AspNetCore.Builder; - -namespace LINGYUN.Abp.Identity.Session.AspNetCore; -public static class AbpSessionApplicationBuilderExtensions -{ - /// - /// 会话管理中间件 - /// - /// - /// 建议顺序:
- ///
- ///
- ///
- ///
- ///
- /// - /// - public static IApplicationBuilder UseAbpSession(this IApplicationBuilder app) - { - return app.UseMiddleware(); - } -} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpSessionMiddleware.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpSessionMiddleware.cs deleted file mode 100644 index f86d2c7a7..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/AbpSessionMiddleware.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; -using System; -using System.Security.Principal; -using System.Threading.Tasks; -using Volo.Abp.AspNetCore.Middleware; -using Volo.Abp.DependencyInjection; -using Volo.Abp.Security.Claims; -using Volo.Abp.Tracing; - -namespace LINGYUN.Abp.Identity.Session.AspNetCore; -public class AbpSessionMiddleware : AbpMiddlewareBase, ITransientDependency -{ - private readonly ISessionInfoProvider _sessionInfoProvider; - private readonly ICorrelationIdProvider _correlationIdProvider; - - public AbpSessionMiddleware( - ISessionInfoProvider sessionInfoProvider, - ICorrelationIdProvider correlationIdProvider) - { - _sessionInfoProvider = sessionInfoProvider; - _correlationIdProvider = correlationIdProvider; - } - - public override Task InvokeAsync(HttpContext context, RequestDelegate next) - { - var sessionId = _correlationIdProvider.Get() ?? Guid.NewGuid().ToString("N"); - if (context.User.Identity?.IsAuthenticated == true) - { - if (context.RequestServices.GetRequiredService>().Value.IsDynamicClaimsEnabled) - { - // 在处理动态声明前保留全局会话用于验证 - sessionId = context.User.FindSessionId(); - } - } - using (_sessionInfoProvider.Change(sessionId)) - { - return next(context); - } - } -} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/README.EN.md b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/README.EN.md deleted file mode 100644 index 4c5ccd8af..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/README.EN.md +++ /dev/null @@ -1,97 +0,0 @@ -# LINGYUN.Abp.Identity.Session.AspNetCore - -Identity service user session extension module. - -## Interface Description - -### AbpSessionMiddleware extracts *sessionId* from user token in the request pipeline as a global session identifier, which can be used to log out sessions -> Note: When anonymous users access, the request *CorrelationId* is used as the identifier; - When *CorrelationId* does not exist, use random *Guid.NewGuid()*. - -### HttpContextDeviceInfoProvider extracts device identification from request parameters - -> Due to module responsibility separation principle, please do not confuse with *LINGYUN.Abp.Identity.AspNetCore.Session* module - -### HttpContextDeviceInfoProvider is used to handle session IP address location parsing - -> IsParseIpLocation will parse the geographical location of session IP when enabled -> IgnoreProvinces are provinces that need to be ignored when parsing geographical locations, usually China's municipalities -> LocationParser customizes the geographical location data that needs to be processed - -## Features - -* Provides session management functionality in AspNetCore environment -* Supports extracting device identification information from requests -* Supports IP geolocation parsing -* Depends on AbpAspNetCoreModule, AbpIP2RegionModule, and AbpIdentitySessionModule - -## Configuration Options - -### AbpIdentitySessionAspNetCoreOptions - -```json -{ - "Identity": { - "Session": { - "AspNetCore": { - "IsParseIpLocation": false, // Whether to parse IP geographic information, default: false - "IgnoreProvinces": [ // Provinces to ignore, default includes China's municipalities - "Beijing", - "Shanghai", - "Tianjin", - "Chongqing" - ] - } - } - } -} -``` - -## Basic Usage - -1. Configure IP geolocation parsing -```csharp -Configure(options => -{ - options.IsParseIpLocation = true; // Enable IP geolocation parsing - options.IgnoreProvinces.Add("Hong Kong"); // Add provinces to ignore - options.LocationParser = (locationInfo) => - { - // Custom geolocation parsing logic - return $"{locationInfo.Country}{locationInfo.Province}{locationInfo.City}"; - }; -}); -``` - -2. Use device information provider -```csharp -public class YourService -{ - private readonly IDeviceInfoProvider _deviceInfoProvider; - - public YourService(IDeviceInfoProvider deviceInfoProvider) - { - _deviceInfoProvider = deviceInfoProvider; - } - - public async Task GetDeviceInfoAsync() - { - return await _deviceInfoProvider.GetDeviceInfoAsync(); - } -} -``` - -## Configuration Usage - -```csharp -[DependsOn(typeof(AbpIdentitySessionAspNetCoreModule))] -public class YouProjectModule : AbpModule -{ - // other -} -``` - -## More Information - -* [ABP Identity Documentation](https://docs.abp.io/en/abp/latest/Identity) -* [ABP AspNetCore Documentation](https://docs.abp.io/en/abp/latest/AspNetCore) diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/README.md b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/README.md deleted file mode 100644 index b5393fddf..000000000 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session.AspNetCore/README.md +++ /dev/null @@ -1,98 +0,0 @@ -# LINGYUN.Abp.Identity.Session.AspNetCore - -身份服务用户会话扩展模块 - -## 接口描述 - -### AbpSessionMiddleware 在请求管道中从用户令牌提取 *sessionId* 作为全局会话标识, 可用于注销会话 -> 注意: 当匿名用户访问时, 以请求 *CorrelationId* 作为标识; - 当 *CorrelationId* 不存在时, 使用随机 *Guid.NewGuid()*. - -### HttpContextDeviceInfoProvider 从请求参数中提取设备标识 - -> 出于模块职责分离原则, 请勿与 *LINGYUN.Abp.Identity.AspNetCore.Session* 模块混淆 - - -### HttpContextDeviceInfoProvider 用于处理会话IP的地址位置解析 - -> IsParseIpLocation 启用后将对会话IP进行地理位置解析 -> IgnoreProvinces 解析地理位置时需要忽略的省份,通常情况下中国的直辖市需要 -> LocationParser 自定义需要处理的地理位置数据 - -## 功能特性 - -* 提供AspNetCore环境下的会话管理功能 -* 支持从请求中提取设备标识信息 -* 支持IP地理位置解析功能 -* 依赖AbpAspNetCoreModule、AbpIP2RegionModule和AbpIdentitySessionModule模块 - -## 配置项 - -### AbpIdentitySessionAspNetCoreOptions - -```json -{ - "Identity": { - "Session": { - "AspNetCore": { - "IsParseIpLocation": false, // 是否解析IP地理信息,默认:false - "IgnoreProvinces": [ // 不做处理的省份,默认包含中国直辖市 - "北京", - "上海", - "天津", - "重庆" - ] - } - } - } -} -``` - -## 基本用法 - -1. 配置IP地理位置解析 -```csharp -Configure(options => -{ - options.IsParseIpLocation = true; // 启用IP地理位置解析 - options.IgnoreProvinces.Add("香港"); // 添加需要忽略的省份 - options.LocationParser = (locationInfo) => - { - // 自定义地理位置解析逻辑 - return $"{locationInfo.Country}{locationInfo.Province}{locationInfo.City}"; - }; -}); -``` - -2. 使用设备信息提供者 -```csharp -public class YourService -{ - private readonly IDeviceInfoProvider _deviceInfoProvider; - - public YourService(IDeviceInfoProvider deviceInfoProvider) - { - _deviceInfoProvider = deviceInfoProvider; - } - - public async Task GetDeviceInfoAsync() - { - return await _deviceInfoProvider.GetDeviceInfoAsync(); - } -} -``` - -## 配置使用 - -```csharp -[DependsOn(typeof(AbpIdentitySessionAspNetCoreModule))] -public class YouProjectModule : AbpModule -{ - // other -} -``` - -## 更多信息 - -* [ABP身份认证文档](https://docs.abp.io/en/abp/latest/Identity) -* [ABP AspNetCore文档](https://docs.abp.io/en/abp/latest/AspNetCore) diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/DefaultIdentitySessionChecker.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/DefaultIdentitySessionChecker.cs index 4c393bc2c..f45134db5 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/DefaultIdentitySessionChecker.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/DefaultIdentitySessionChecker.cs @@ -69,11 +69,11 @@ public class DefaultIdentitySessionChecker : IIdentitySessionChecker, ITransient // Implementation https://github.com/abpio/abp-commercial-docs/blob/dev/en/modules/identity/session-management.md#how-it-works - var lastAccressedTime = identitySessionCacheItem.LastAccessed; + var lastAccessedTime = identitySessionCacheItem.LastAccessed; var accressedTime = Clock.Now; - if (lastAccressedTime.HasValue && - lastAccressedTime.Value < accressedTime.Subtract(SessionCheckOptions.KeepAccessTimeSpan)) + if (lastAccessedTime.HasValue && + lastAccessedTime.Value < accressedTime.Subtract(SessionCheckOptions.KeepAccessTimeSpan)) { // 更新缓存中的访问地址以及客户端Ip地址 identitySessionCacheItem.LastAccessed = accressedTime; @@ -89,15 +89,15 @@ public class DefaultIdentitySessionChecker : IIdentitySessionChecker, ITransient // identitySessionCacheItem.ExpiraIn = (expirainTime.Value - timestamp) * 1000; //} - Logger.LogDebug($"Refresh the user access info in the cache from {sessionId}."); + Logger.LogDebug("Refresh the user access info in the cache from {sessionId}.", sessionId); await IdentitySessionCache.RefreshAsync(sessionId, identitySessionCacheItem, cancellationToken); } // 避免某些场景频繁去刷新持久化设施 - if (lastAccressedTime.HasValue && - lastAccressedTime.Value < accressedTime.Subtract(SessionCheckOptions.SessionSyncTimeSpan)) + if (lastAccessedTime.HasValue && + lastAccessedTime.Value < accressedTime.Subtract(SessionCheckOptions.SessionSyncTimeSpan)) { - Logger.LogDebug($"Publishes the cache synchronization user session event from {sessionId}."); + Logger.LogDebug("Publishes the cache synchronization user session event from {sessionId}.", sessionId); // 发布事件, 使持久化设施从缓存同步 var eventData = new IdentitySessionChangeAccessedEvent( identitySessionCacheItem.SessionId, diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/DefaultSessionInfoProvider.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/DefaultSessionInfoProvider.cs index 237420ca7..b56295472 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/DefaultSessionInfoProvider.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/DefaultSessionInfoProvider.cs @@ -7,6 +7,7 @@ using Volo.Abp.DependencyInjection; namespace LINGYUN.Abp.Identity.Session; [Dependency(ServiceLifetime.Singleton, TryRegister = true)] +[Obsolete("The ISessionInfoProvider has been deprecated. Please use ICurrentUser.FindSessionId() instead.")] public class DefaultSessionInfoProvider : ISessionInfoProvider { private readonly AsyncLocal _currentSessionId = new AsyncLocal(); diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/ISessionInfoProvider.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/ISessionInfoProvider.cs index 29ceb05e3..936a6bf6a 100644 --- a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/ISessionInfoProvider.cs +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/ISessionInfoProvider.cs @@ -1,6 +1,8 @@ using System; namespace LINGYUN.Abp.Identity.Session; + +[Obsolete("The ISessionInfoProvider has been deprecated. Please use ICurrentUser.FindSessionId() instead.")] public interface ISessionInfoProvider { string? SessionId { get; } diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/FodyWeavers.xml b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/FodyWeavers.xml deleted file mode 100644 index 5d6962159..000000000 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/FodyWeavers.xsd b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/FodyWeavers.xsd deleted file mode 100644 index 3f3946e28..000000000 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/FodyWeavers.xsd +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. - - - - - A comma-separated list of error codes that can be safely ignored in assembly verification. - - - - - 'false' to turn off automatic generation of the XML Schema file. - - - - - \ No newline at end of file diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN.Abp.IdentityServer.Session.csproj b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN.Abp.IdentityServer.Session.csproj deleted file mode 100644 index ee10322e9..000000000 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN.Abp.IdentityServer.Session.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - net10.0 - LINGYUN.Abp.IdentityServer.Session - LINGYUN.Abp.IdentityServer.Session - false - false - false - - - - - - - - - - diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/AbpIdentityServerSessionModule.cs b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/AbpIdentityServerSessionModule.cs deleted file mode 100644 index 9c9506742..000000000 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/AbpIdentityServerSessionModule.cs +++ /dev/null @@ -1,42 +0,0 @@ -using IdentityServer4.Validation; -using LINGYUN.Abp.Identity; -using LINGYUN.Abp.Identity.Session; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Volo.Abp.IdentityServer; -using Volo.Abp.Modularity; -using Volo.Abp.Security.Claims; - -namespace LINGYUN.Abp.IdentityServer.Session; - -[DependsOn( - typeof(AbpIdentityServerDomainModule), - typeof(AbpIdentityDomainModule), - typeof(AbpIdentitySessionModule))] -public class AbpIdentityServerSessionModule : AbpModule -{ - public override void ConfigureServices(ServiceConfigurationContext context) - { - Configure(options => - { - options.EventServiceHandlers.Add(); - }); - - Configure(options => - { - options.RequestedClaims.Add(AbpClaimTypes.SessionId); - }); - - Configure(options => - { - // UserLoginSuccessEvent由IdentityServer发布, 无需显式保存会话 - options.SignInSessionEnabled = false; - // UserLoginSuccessEvent由用户发布, 需要显式注销会话 - options.SignOutSessionEnabled = true; - }); - - // 默认UserinfoEndpoint仅解密token - // 启用此模块需要验证会话有效性 - context.Services.Replace(ServiceDescriptor.Transient()); - } -} diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/AbpIdentitySessionEventServiceHandler.cs b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/AbpIdentitySessionEventServiceHandler.cs deleted file mode 100644 index c28a06163..000000000 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/LINGYUN/Abp/IdentityServer/Session/AbpIdentitySessionEventServiceHandler.cs +++ /dev/null @@ -1,102 +0,0 @@ -using IdentityServer4.Events; -using LINGYUN.Abp.Identity.Session; -using System; -using System.Security.Claims; -using System.Threading.Tasks; -using Volo.Abp.DependencyInjection; -using Volo.Abp.MultiTenancy; -using Volo.Abp.Security.Claims; -using Volo.Abp.Uow; - -namespace LINGYUN.Abp.IdentityServer.Session; -/// -/// 持久化用户会话 -/// -public class AbpIdentitySessionEventServiceHandler : IAbpIdentityServerEventServiceHandler, ITransientDependency -{ - protected ICurrentTenant CurrentTenant { get; } - protected ISessionInfoProvider SessionInfoProvider { get; } - protected IIdentitySessionManager IdentitySessionManager { get; } - protected ICurrentPrincipalAccessor CurrentPrincipalAccessor { get; } - - public AbpIdentitySessionEventServiceHandler( - ICurrentTenant currentTenant, - ISessionInfoProvider sessionInfoProvider, - IIdentitySessionManager identitySessionManager, - ICurrentPrincipalAccessor currentPrincipalAccessor) - { - CurrentTenant = currentTenant; - SessionInfoProvider = sessionInfoProvider; - IdentitySessionManager = identitySessionManager; - CurrentPrincipalAccessor = currentPrincipalAccessor; - } - - public virtual bool CanRaiseEventType(EventTypes evtType) - { - return evtType == EventTypes.Success; - } - - [UnitOfWork] - public virtual Task RaiseAsync(Event evt) - { - if (evt is UserLoginSuccessEvent loginEvent) - { - // 用户登录事件 - return RaiseUserLoginSuccessEventAsync(loginEvent); - } - if (evt is UserLogoutSuccessEvent logoutEvent) - { - // 用户退出事件 - return RaiseUserLogoutSuccessEventAsync(logoutEvent); - } - if (evt is TokenRevokedSuccessEvent revokeEvent) - { - // 撤销令牌事件 - return RaiseTokenRevokedSuccessEventAsync(revokeEvent); - } - return Task.CompletedTask; - } - - protected async virtual Task RaiseUserLoginSuccessEventAsync(UserLoginSuccessEvent loginEvent) - { - var subjectId = loginEvent.SubjectId; - var sessionId = SessionInfoProvider.SessionId; - if (!sessionId.IsNullOrWhiteSpace() && - Guid.TryParse(subjectId, out var userId)) - { - var claimsIdentity = new ClaimsIdentity(); - claimsIdentity.AddClaim(new Claim(AbpClaimTypes.UserId, userId.ToString())); - claimsIdentity.AddClaim(new Claim(AbpClaimTypes.SessionId, sessionId)); - if (!loginEvent.ClientId.IsNullOrWhiteSpace()) - { - claimsIdentity.AddClaim(new Claim(AbpClaimTypes.ClientId, loginEvent.ClientId)); - } - if (CurrentTenant.IsAvailable) - { - claimsIdentity.AddClaim(new Claim(AbpClaimTypes.TenantId, CurrentTenant.Id!.Value.ToString())); - } - var claimsPrincipal = new ClaimsPrincipal(claimsIdentity); - using (CurrentPrincipalAccessor.Change(claimsPrincipal)) - { - await IdentitySessionManager.SaveSessionAsync(claimsPrincipal); - } - } - } - protected async virtual Task RaiseUserLogoutSuccessEventAsync(UserLogoutSuccessEvent logoutEvent) - { - var sessionId = SessionInfoProvider.SessionId; - if (!sessionId.IsNullOrWhiteSpace()) - { - await IdentitySessionManager.RevokeSessionAsync(sessionId); - } - } - - protected async virtual Task RaiseTokenRevokedSuccessEventAsync(TokenRevokedSuccessEvent revokeEvent) - { - var sessionId = SessionInfoProvider.SessionId; - if (!sessionId.IsNullOrWhiteSpace()) - { - await IdentitySessionManager.RevokeSessionAsync(sessionId); - } - } -} diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/README.EN.md b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/README.EN.md deleted file mode 100644 index b8f528fb7..000000000 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/README.EN.md +++ /dev/null @@ -1,77 +0,0 @@ -# LINGYUN.Abp.IdentityServer.Session - -IdentityServer session management module that provides user session management and validation functionality. - -## Features - -* Session Validation - * `AbpIdentitySessionUserInfoRequestValidator` - User Info Request Validator - * Validates user session status - * Validates access token validity - * Validates user active status - * Supports OpenID Connect standard - -* Session Event Handling - * `AbpIdentitySessionEventServiceHandler` - Session Event Handler - * Handles user login success events - * Saves session information - * Supports multi-tenancy - * Records client identifier - * Handles user logout success events - * Revokes session - * Handles token revocation success events - * Revokes session - -* Configuration Options - * Session Claims Configuration - * Add SessionId claim - * Session Login Configuration - * Disable explicit session saving - * Enable explicit session logout - -## Module Reference - -```csharp -[DependsOn( - typeof(AbpIdentityServerSessionModule) -)] -public class YourModule : AbpModule -{ - // ... -} -``` - -## Dependencies - -* `AbpIdentityServerDomainModule` - ABP IdentityServer Domain Module -* `AbpIdentityDomainModule` - ABP Identity Domain Module -* `AbpIdentitySessionModule` - ABP Identity Session Module - -## Configuration and Usage - -### Configure Session Options - -```csharp -Configure(options => -{ - // UserLoginSuccessEvent is published by IdentityServer, no need for explicit session saving - options.SignInSessionEnabled = false; - // UserLoginSuccessEvent is published by user, requires explicit session logout - options.SignOutSessionEnabled = true; -}); -``` - -### Configure Claims Options - -```csharp -Configure(options => -{ - options.RequestedClaims.Add(AbpClaimTypes.SessionId); -}); -``` - -Related Documentation: -* [IdentityServer4 Documentation](https://identityserver4.readthedocs.io/) -* [ABP Identity Documentation](https://docs.abp.io/en/abp/latest/Modules/Identity) - -[查看中文文档](README.md) diff --git a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/README.md b/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/README.md deleted file mode 100644 index 15eef870c..000000000 --- a/aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.Session/README.md +++ /dev/null @@ -1,77 +0,0 @@ -# LINGYUN.Abp.IdentityServer.Session - -IdentityServer会话管理模块,提供用户会话管理和验证功能。 - -## 功能特性 - -* 会话验证 - * `AbpIdentitySessionUserInfoRequestValidator` - 用户信息请求验证器 - * 验证用户会话状态 - * 验证访问令牌有效性 - * 验证用户活动状态 - * 支持OpenID Connect标准 - -* 会话事件处理 - * `AbpIdentitySessionEventServiceHandler` - 会话事件处理器 - * 处理用户登录成功事件 - * 保存会话信息 - * 支持多租户 - * 记录客户端标识 - * 处理用户登出成功事件 - * 撤销会话 - * 处理令牌撤销成功事件 - * 撤销会话 - -* 配置选项 - * 会话声明配置 - * 添加SessionId声明 - * 会话登录配置 - * 禁用显式保存会话 - * 启用显式注销会话 - -## 模块引用 - -```csharp -[DependsOn( - typeof(AbpIdentityServerSessionModule) -)] -public class YourModule : AbpModule -{ - // ... -} -``` - -## 依赖模块 - -* `AbpIdentityServerDomainModule` - ABP IdentityServer领域模块 -* `AbpIdentityDomainModule` - ABP Identity领域模块 -* `AbpIdentitySessionModule` - ABP Identity会话模块 - -## 配置使用 - -### 配置会话选项 - -```csharp -Configure(options => -{ - // UserLoginSuccessEvent由IdentityServer发布, 无需显式保存会话 - options.SignInSessionEnabled = false; - // UserLoginSuccessEvent由用户发布, 需要显式注销会话 - options.SignOutSessionEnabled = true; -}); -``` - -### 配置声明选项 - -```csharp -Configure(options => -{ - options.RequestedClaims.Add(AbpClaimTypes.SessionId); -}); -``` - -相关文档: -* [IdentityServer4文档](https://identityserver4.readthedocs.io/) -* [ABP Identity文档](https://docs.abp.io/en/abp/latest/Modules/Identity) - -[查看英文文档](README.EN.md) diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/FodyWeavers.xml b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/FodyWeavers.xml deleted file mode 100644 index 1715698cc..000000000 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/FodyWeavers.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/FodyWeavers.xsd b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/FodyWeavers.xsd deleted file mode 100644 index 3f3946e28..000000000 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/FodyWeavers.xsd +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. - - - - - A comma-separated list of error codes that can be safely ignored in assembly verification. - - - - - 'false' to turn off automatic generation of the XML Schema file. - - - - - \ No newline at end of file diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN.Abp.OpenIddict.AspNetCore.Session.csproj b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN.Abp.OpenIddict.AspNetCore.Session.csproj deleted file mode 100644 index c7affde96..000000000 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN.Abp.OpenIddict.AspNetCore.Session.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - net10.0 - LINGYUN.Abp.OpenIddict.AspNetCore.Session - LINGYUN.Abp.OpenIddict.AspNetCore.Session - false - false - false - - - - - - - - - - - - - diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/AbpOpenIddictAspNetCoreSessionModule.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/AbpOpenIddictAspNetCoreSessionModule.cs deleted file mode 100644 index ae2d0f113..000000000 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/AbpOpenIddictAspNetCoreSessionModule.cs +++ /dev/null @@ -1,54 +0,0 @@ -using LINGYUN.Abp.Identity; -using LINGYUN.Abp.Identity.Session; -using LINGYUN.Abp.Identity.Session.AspNetCore; -using Microsoft.Extensions.DependencyInjection; -using OpenIddict.Server; -using OpenIddict.Validation; -using Volo.Abp.Modularity; -using static OpenIddict.Abstractions.OpenIddictConstants; - -namespace LINGYUN.Abp.OpenIddict.AspNetCore.Session; - -[DependsOn( - typeof(AbpIdentityDomainModule), - typeof(AbpIdentitySessionAspNetCoreModule) - )] -public class AbpOpenIddictAspNetCoreSessionModule : AbpModule -{ - public override void PreConfigureServices(ServiceConfigurationContext context) - { - PreConfigure(builder => - { - builder.AddEventHandler(ProcessSignOutIdentitySession.Descriptor); - builder.AddEventHandler(ProcessSignInIdentitySession.Descriptor); - builder.AddEventHandler(RevocationIdentitySession.Descriptor); - builder.AddEventHandler(ServerValidationTokenCheckIdentitySession.Descriptor); - // builder.AddEventHandler(UserInfoIdentitySession.Descriptor); - }); - } - - public override void ConfigureServices(ServiceConfigurationContext context) - { - Configure(options => - { - options.SignInSessionEnabled = true; - options.SignOutSessionEnabled = true; - }); - - Configure(options => - { - options.PersistentSessionGrantTypes.Add(GrantTypes.Password); - options.ValidationSessionEndpointTypes.Add(OpenIddictServerEndpointType.Token); - options.ValidationSessionEndpointTypes.Add(OpenIddictServerEndpointType.UserInfo); - options.ValidationSessionEndpointTypes.Add(OpenIddictServerEndpointType.Introspection); - options.ValidationSessionEndpointTypes.Add(OpenIddictServerEndpointType.Revocation); - }); - - context.Services.Add(ValidationTokenCheckIdentitySession.Descriptor.ServiceDescriptor); - - Configure(options => - { - options.Handlers.Add(ValidationTokenCheckIdentitySession.Descriptor); - }); - } -} diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/AbpOpenIddictAspNetCoreSessionOptions.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/AbpOpenIddictAspNetCoreSessionOptions.cs deleted file mode 100644 index 80411f605..000000000 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/AbpOpenIddictAspNetCoreSessionOptions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using OpenIddict.Server; -using System.Collections.Generic; - -namespace LINGYUN.Abp.OpenIddict.AspNetCore.Session; -public class AbpOpenIddictAspNetCoreSessionOptions -{ - public List PersistentSessionGrantTypes { get; set; } - public List ValidationSessionEndpointTypes { get; set; } - public AbpOpenIddictAspNetCoreSessionOptions() - { - PersistentSessionGrantTypes = new List(); - ValidationSessionEndpointTypes = new List(); - } -} diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ProcessSignInIdentitySession.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ProcessSignInIdentitySession.cs deleted file mode 100644 index 2373b9077..000000000 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/ProcessSignInIdentitySession.cs +++ /dev/null @@ -1,56 +0,0 @@ -using LINGYUN.Abp.Identity.Session; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; -using OpenIddict.Server; -using System; -using System.Security.Principal; -using System.Threading.Tasks; - -namespace LINGYUN.Abp.OpenIddict.AspNetCore.Session; -/// -/// 登录成功持久化用户会话 -/// -public class ProcessSignInIdentitySession : IOpenIddictServerHandler -{ - public ILogger Logger { protected get; set; } - - protected IIdentitySessionManager IdentitySessionManager { get; } - protected AbpOpenIddictAspNetCoreSessionOptions AbpOpenIddictAspNetCoreSessionOptions { get; } - - public static OpenIddictServerHandlerDescriptor Descriptor { get; } - = OpenIddictServerHandlerDescriptor.CreateBuilder() - .AddFilter() - .UseScopedHandler() - .SetOrder(OpenIddictServerHandlers.PrepareAccessTokenPrincipal.Descriptor.Order + 1_000) - .SetType(OpenIddictServerHandlerType.Custom) - .Build(); - - public ProcessSignInIdentitySession( - IIdentitySessionManager identitySessionManager, - IOptions abpOpenIddictAspNetCoreSessionOptions) - { - IdentitySessionManager = identitySessionManager; - AbpOpenIddictAspNetCoreSessionOptions = abpOpenIddictAspNetCoreSessionOptions.Value; - - Logger = NullLogger.Instance; - } - - public async virtual ValueTask HandleAsync(OpenIddictServerEvents.ProcessSignInContext context) - { - if (!context.Request.GrantType.IsNullOrWhiteSpace() && - AbpOpenIddictAspNetCoreSessionOptions.PersistentSessionGrantTypes.Contains(context.Request.GrantType) && - context.Principal != null) - { - Logger.LogInformation("Saving session for grant type: {grantType}", context.Request.GrantType); - - await IdentitySessionManager.SaveSessionAsync(context.Principal, context.CancellationToken); - - Logger.LogInformation("Session saved successfully: {sessionId}", context.Principal.FindSessionId()); - } - else - { - Logger.LogDebug("Skipping session save for grant type: {grantType}", context.Request.GrantType); - } - } -} diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/UserinfoIdentitySession.cs b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/UserinfoIdentitySession.cs deleted file mode 100644 index 23fbe6c4f..000000000 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/LINGYUN/Abp/OpenIddict/AspNetCore/Session/UserinfoIdentitySession.cs +++ /dev/null @@ -1,49 +0,0 @@ -using LINGYUN.Abp.Identity.Session; -using OpenIddict.Server; -using System; -using System.Security.Principal; -using System.Threading.Tasks; -using Volo.Abp.MultiTenancy; -using static OpenIddict.Abstractions.OpenIddictConstants; -using static OpenIddict.Server.OpenIddictServerHandlers.UserInfo; - -namespace LINGYUN.Abp.OpenIddict.AspNetCore.Session; -/// -/// UserInfoEndpoint 检查用户会话 -/// -[Obsolete("UserInfoIdentitySession is outdated, please use the CheckIdentitySessionOnServerValidationToken")] -public class UserInfoIdentitySession : IOpenIddictServerHandler -{ - protected ICurrentTenant CurrentTenant { get; } - protected IIdentitySessionChecker IdentitySessionChecker { get; } - - public static OpenIddictServerHandlerDescriptor Descriptor { get; } - = OpenIddictServerHandlerDescriptor.CreateBuilder() - .AddFilter() - .UseScopedHandler() - .SetOrder(ValidateUserInfoRequest.Descriptor.Order + 2_000) - .SetType(OpenIddictServerHandlerType.Custom) - .Build(); - - public UserInfoIdentitySession( - ICurrentTenant currentTenant, - IIdentitySessionChecker identitySessionChecker) - { - CurrentTenant = currentTenant; - IdentitySessionChecker = identitySessionChecker; - } - - public async virtual ValueTask HandleAsync(OpenIddictServerEvents.HandleUserInfoRequestContext context) - { - var tenantId = context.AccessTokenPrincipal.FindTenantId(); - using (CurrentTenant.Change(tenantId)) - { - if (!await IdentitySessionChecker.ValidateSessionAsync(context.AccessTokenPrincipal)) - { - // Errors.InvalidToken ---> 401 - // Errors.ExpiredToken ---> 400 - context.Reject(Errors.InvalidToken, "The user session has expired."); - } - } - } -} diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/README.EN.md b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/README.EN.md deleted file mode 100644 index 6c3619f3a..000000000 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/README.EN.md +++ /dev/null @@ -1,76 +0,0 @@ -# LINGYUN.Abp.OpenIddict.AspNetCore.Session - -[![ABP version](https://img.shields.io/badge/dynamic/xml?style=flat-square&color=yellow&label=abp&query=%2F%2FProject%2FPropertyGroup%2FAbpVersion&url=https%3A%2F%2Fraw.githubusercontent.com%2Fcolinin%2Fabp-next-admin%2Fmaster%2Faspnet-core%2Fmodules%2FopenIddict%2FLINGYUN.Abp.OpenIddict.AspNetCore.Session%2FLINGYUN.Abp.OpenIddict.AspNetCore.Session.csproj)](https://abp.io) -[![NuGet](https://img.shields.io/nuget/v/LINGYUN.Abp.OpenIddict.AspNetCore.Session.svg?style=flat-square)](https://www.nuget.org/packages/LINGYUN.Abp.OpenIddict.AspNetCore.Session) - -## Introduction - -`LINGYUN.Abp.OpenIddict.AspNetCore.Session` is a session management extension module for OpenIddict, providing functionality for user session persistence, validation, and revocation. - -[简体中文](./README.md) - -## Features - -* User Session Management - * Automatic session persistence on login - * Automatic session termination on logout - * Automatic session termination on token revocation - * UserInfo endpoint session validation - -* Multi-tenancy Support - * Session management supports multi-tenant scenarios - * Tenant-isolated session storage - -* Configurable Session Persistence - * Support for configuring grant types that require session persistence - * Default support for password grant type - -## Installation - -```bash -dotnet add package LINGYUN.Abp.OpenIddict.AspNetCore.Session -``` - -## Usage - -1. Add `[DependsOn(typeof(AbpOpenIddictAspNetCoreSessionModule))]` to your module class. - -2. Configure session options: - -```csharp -Configure(options => -{ - options.SignInSessionEnabled = true; // Enable login session - options.SignOutSessionEnabled = true; // Enable logout session -}); - -Configure(options => -{ - // Configure grant types that require session persistence - options.PersistentSessionGrantTypes.Add(GrantTypes.Password); - options.PersistentSessionGrantTypes.Add("custom_grant_type"); -}); -``` - -## Workflow - -1. User Login - * When a user successfully logs in through configured grant types - * System automatically creates and persists session information - -2. Session Validation - * When user accesses the UserInfo endpoint - * System automatically validates if the session is valid - * Returns appropriate error if session has expired or is invalid - -3. Session Termination - * Automatically terminates session on user logout - * Automatically terminates related sessions on token revocation - * Supports session management for multiple concurrent logins - -## Notes - -* Session persistence only applies to configured grant types -* Session validation automatically switches tenant context in multi-tenant environments -* Token revocation will terminate related user sessions -* UserInfo endpoint session validation is mandatory, invalid sessions will result in request rejection diff --git a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/README.md b/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/README.md deleted file mode 100644 index 93f8f6743..000000000 --- a/aspnet-core/modules/openIddict/LINGYUN.Abp.OpenIddict.AspNetCore.Session/README.md +++ /dev/null @@ -1,76 +0,0 @@ -# LINGYUN.Abp.OpenIddict.AspNetCore.Session - -[![ABP version](https://img.shields.io/badge/dynamic/xml?style=flat-square&color=yellow&label=abp&query=%2F%2FProject%2FPropertyGroup%2FAbpVersion&url=https%3A%2F%2Fraw.githubusercontent.com%2Fcolinin%2Fabp-next-admin%2Fmaster%2Faspnet-core%2Fmodules%2FopenIddict%2FLINGYUN.Abp.OpenIddict.AspNetCore.Session%2FLINGYUN.Abp.OpenIddict.AspNetCore.Session.csproj)](https://abp.io) -[![NuGet](https://img.shields.io/nuget/v/LINGYUN.Abp.OpenIddict.AspNetCore.Session.svg?style=flat-square)](https://www.nuget.org/packages/LINGYUN.Abp.OpenIddict.AspNetCore.Session) - -## 简介 - -`LINGYUN.Abp.OpenIddict.AspNetCore.Session` 是 OpenIddict 的会话管理扩展模块,提供了用户会话的持久化、验证和撤销功能。 - -[English](./README.EN.md) - -## 功能特性 - -* 用户会话管理 - * 登录时自动持久化会话 - * 登出时自动终止会话 - * 令牌撤销时自动终止会话 - * UserInfo 端点会话验证 - -* 多租户支持 - * 会话管理支持多租户场景 - * 租户隔离的会话存储 - -* 可配置的会话持久化 - * 支持配置需要持久化会话的授权类型 - * 默认支持密码授权类型 - -## 安装 - -```bash -dotnet add package LINGYUN.Abp.OpenIddict.AspNetCore.Session -``` - -## 使用 - -1. 添加 `[DependsOn(typeof(AbpOpenIddictAspNetCoreSessionModule))]` 到你的模块类。 - -2. 配置会话选项: - -```csharp -Configure(options => -{ - options.SignInSessionEnabled = true; // 启用登录会话 - options.SignOutSessionEnabled = true; // 启用登出会话 -}); - -Configure(options => -{ - // 配置需要持久化会话的授权类型 - options.PersistentSessionGrantTypes.Add(GrantTypes.Password); - options.PersistentSessionGrantTypes.Add("custom_grant_type"); -}); -``` - -## 工作流程 - -1. 用户登录 - * 当用户通过配置的授权类型登录成功时 - * 系统自动创建并持久化会话信息 - -2. 会话验证 - * 当用户访问 UserInfo 端点时 - * 系统自动验证会话是否有效 - * 如果会话已过期或无效,返回相应的错误 - -3. 会话终止 - * 用户主动登出时自动终止会话 - * 令牌撤销时自动终止相关会话 - * 支持多终端同时登录的会话管理 - -## 注意事项 - -* 会话持久化仅对配置的授权类型生效 -* 会话验证在多租户环境中会自动切换租户上下文 -* 令牌撤销会同时终止相关的用户会话 -* UserInfo 端点的会话验证是强制的,无效会话将导致请求被拒绝 diff --git a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs index 6eb9a5c36..e32dd36a5 100644 --- a/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs +++ b/aspnet-core/modules/text-templating/LINGYUN.Abp.TextTemplating.Scriban/LINGYUN/Abp/TextTemplating/Scriban/ScribanTemplateRenderingEngine.cs @@ -14,6 +14,7 @@ public class ScribanTemplateRenderingEngine : TemplateRenderingEngineBase, ITran { public const string EngineName = "Scriban"; public override string Name => EngineName; + public override bool IsSandboxed => true; public ScribanTemplateRenderingEngine( ITemplateDefinitionManager templateDefinitionManager, diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/GlobalUsings.cs b/aspnet-core/services/LY.MicroService.Applications.Single/GlobalUsings.cs index 977133228..5376f3ee9 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/GlobalUsings.cs +++ b/aspnet-core/services/LY.MicroService.Applications.Single/GlobalUsings.cs @@ -16,6 +16,7 @@ global using LINGYUN.Abp.AspNetCore.MultiTenancy; global using LINGYUN.Abp.AspNetCore.Mvc.Idempotent.Wrapper; global using LINGYUN.Abp.AspNetCore.Mvc.UI.MultiTenancy; global using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +global using LINGYUN.Abp.AspNetCore.Session; global using LINGYUN.Abp.Auditing; global using LINGYUN.Abp.AuditLogging.EntityFrameworkCore; global using LINGYUN.Abp.AuditLogging.IP.Location; @@ -37,6 +38,7 @@ global using LINGYUN.Abp.BlobManagement.Tencent; global using LINGYUN.Abp.BlobStoring.BlobManagement; global using LINGYUN.Abp.CachingManagement; global using LINGYUN.Abp.CachingManagement.StackExchangeRedis; +global using LINGYUN.Abp.Claims.Mapping; global using LINGYUN.Abp.Dapr.Client; global using LINGYUN.Abp.Data.DbMigrator; global using LINGYUN.Abp.DataProtectionManagement; @@ -64,14 +66,11 @@ global using LINGYUN.Abp.Http.Client.Wrapper; global using LINGYUN.Abp.Idempotent; global using LINGYUN.Abp.Identity; global using LINGYUN.Abp.Identity.AspNetCore; -global using LINGYUN.Abp.Identity.AspNetCore.Session; global using LINGYUN.Abp.Identity.EntityFrameworkCore; global using LINGYUN.Abp.Identity.Jobs; global using LINGYUN.Abp.Identity.Notifications; global using LINGYUN.Abp.Identity.OrganizaztionUnits; -global using LINGYUN.Abp.Identity.QrCode; global using LINGYUN.Abp.Identity.Session; -global using LINGYUN.Abp.Identity.Session.AspNetCore; global using LINGYUN.Abp.Identity.WeChat; global using LINGYUN.Abp.Identity.WeChat.Work; global using LINGYUN.Abp.IdGenerator; @@ -95,7 +94,6 @@ global using LINGYUN.Abp.Notifications.WeChat.MiniProgram; global using LINGYUN.Abp.Notifications.WeChat.Work; global using LINGYUN.Abp.OpenApi.Authorization; global using LINGYUN.Abp.OpenIddict; -global using LINGYUN.Abp.OpenIddict.AspNetCore.Session; global using LINGYUN.Abp.OpenIddict.LinkUser; global using LINGYUN.Abp.OpenIddict.Permissions; global using LINGYUN.Abp.OpenIddict.Portal; @@ -172,6 +170,7 @@ global using OpenIddict.Server; global using OpenIddict.Server.AspNetCore; global using OpenIddict.Validation.AspNetCore; global using Quartz; +global using Serilog; global using StackExchange.Redis; global using Swashbuckle.AspNetCore.SwaggerGen; global using System.Security.Cryptography; @@ -205,11 +204,13 @@ global using Volo.Abp.Http.Client.IdentityModel.Web; global using Volo.Abp.Identity.Localization; global using Volo.Abp.Identity.Web; global using Volo.Abp.Imaging; +global using Volo.Abp.IO; global using Volo.Abp.Json; global using Volo.Abp.Json.SystemTextJson; global using Volo.Abp.Localization; global using Volo.Abp.MailKit; global using Volo.Abp.Modularity; +global using Volo.Abp.Modularity.PlugIns; global using Volo.Abp.MultiTenancy; global using Volo.Abp.OpenIddict; global using Volo.Abp.OpenIddict.EntityFrameworkCore; diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj b/aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj index a7cc3ee35..aa96decc4 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj +++ b/aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj @@ -76,6 +76,7 @@ + @@ -189,7 +190,6 @@ - @@ -197,14 +197,12 @@ - - diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs index 13fd164bb..77dbff181 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs @@ -243,17 +243,6 @@ public partial class MicroServiceApplicationsSingleModule options.DisableTransportSecurityRequirement = true; }); - Configure(options => - { - options.PersistentSessionGrantTypes.Add(SmsTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(PortalTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(LinkUserTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(WeChatTokenExtensionGrantConsts.OfficialGrantType); - options.PersistentSessionGrantTypes.Add(WeChatTokenExtensionGrantConsts.MiniProgramGrantType); - options.PersistentSessionGrantTypes.Add(AbpWeChatWorkGlobalConsts.GrantType); - options.PersistentSessionGrantTypes.Add(QrCodeLoginProviderConsts.GrantType); - }); - Configure(options => { var lifetime = configuration.GetSection("OpenIddict:Lifetime"); @@ -863,7 +852,7 @@ public partial class MicroServiceApplicationsSingleModule options.ExposeIntegrationServices = true; }); - Configure(options => + Configure(options => { // abp 9.0版本可存储登录IP地域, 开启IP解析 options.IsParseIpLocation = true; diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs index 4c6282f72..826876310 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs +++ b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs @@ -11,10 +11,6 @@ namespace LY.MicroService.Applications.Single; typeof(AbpAspNetCoreSerilogModule), // 身份认证模块 扩展UserToken验证 typeof(AbpIdentityAspNetCoreModule), - // 身份认证模块 会话管理集成 - typeof(AbpIdentityAspNetCoreSessionModule), - // 身份认证模块 会话中间件 - typeof(AbpIdentitySessionAspNetCoreModule), // 身份认证模块 通知集成 typeof(AbpIdentityNotificationsModule), // 身份认证模块 组织机构集成 @@ -102,8 +98,6 @@ namespace LY.MicroService.Applications.Single; // 通知模块 实体框架 typeof(AbpNotificationsEntityFrameworkCoreModule), - // OpenIddict扩展模块 会话 - typeof(AbpOpenIddictAspNetCoreSessionModule), // OpenIddict扩展模块 应用服务 typeof(AbpOpenIddictApplicationModule), // OpenIddict扩展模块 控制器 @@ -396,12 +390,14 @@ namespace LY.MicroService.Applications.Single; typeof(AbpLoggingSerilogElasticsearchModule), typeof(AbpHttpClientWrapperModule), typeof(AbpAspNetCoreMvcWrapperModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcIdempotentWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpHttpClientIdentityModelWebModule), typeof(AbpAspNetCoreMultiTenancyModule), typeof(AbpAspNetCoreMvcUiMultiTenancyModule), typeof(AbpDynamicDefinitionsModule), + typeof(AbpClaimsMappingModule), typeof(AbpSwashbuckleModule), typeof(AbpMailKitModule), typeof(AbpAutofacModule), diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/Program.cs b/aspnet-core/services/LY.MicroService.Applications.Single/Program.cs index 6987cf383..2dec70d4b 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/Program.cs +++ b/aspnet-core/services/LY.MicroService.Applications.Single/Program.cs @@ -1,7 +1,4 @@ using LY.MicroService.Applications.Single; -using Serilog; -using Volo.Abp.IO; -using Volo.Abp.Modularity.PlugIns; var builder = WebApplication.CreateBuilder(args); builder.Host.AddAppSettingsSecretsJson() @@ -58,17 +55,19 @@ app.UseAuthentication(); app.UseAbpOpenIddictValidation(); app.UseMultiTenancy(); app.UseUnitOfWork(); -app.UseAbpSession(); app.UseDynamicClaims(); app.UseAuthorization(); -app.UseSwagger(); -app.UseAbpSwaggerUI(options => +if (app.Environment.IsDevelopment()) { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support Single APP API"); + app.UseSwagger(); + app.UseAbpSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support Single APP API"); - options.OAuthClientId(app.Configuration["AuthServer:SwaggerClientId"]); - options.OAuthScopes(app.Configuration["AuthServer:Audience"]); -}); + options.OAuthClientId(app.Configuration["AuthServer:SwaggerClientId"]); + options.OAuthScopes(app.Configuration["AuthServer:Audience"]); + }); +} app.UseAuditing(); app.UseAbpSerilogEnrichers(); app.UseConfiguredEndpoints(); 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 784ca039b..14e538fc1 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs @@ -1,6 +1,7 @@ using LINGYUN.Abp.Account; using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.BlobStoring.BlobManagement; @@ -16,7 +17,6 @@ using LINGYUN.Abp.Gdpr.EntityFrameworkCore; using LINGYUN.Abp.Gdpr.Identity; using LINGYUN.Abp.Identity; using LINGYUN.Abp.Identity.EntityFrameworkCore; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.OpenIddict; @@ -80,7 +80,7 @@ namespace LY.MicroService.AuthServer; typeof(AbpLocalizationCultureMapModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule), typeof(AbpHttpClientIdentityModelWebModule), - typeof(AbpIdentitySessionAspNetCoreModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), typeof(AbpAspNetCoreMvcWrapperModule), @@ -150,8 +150,6 @@ public partial class AuthServerHttpApiHostModule : AbpModule app.UseAuthentication(); // 多租户 app.UseMultiTenancy(); - // 会话 - app.UseAbpSession(); // 动态身份 app.UseDynamicClaims(); // 授权 diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj index 6288562b5..05f7887ed 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/LY.MicroService.AuthServer.HttpApi.Host.csproj @@ -46,6 +46,7 @@ + @@ -67,7 +68,6 @@ - diff --git a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs index 7e406a7f9..e9435eb30 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs @@ -3,15 +3,9 @@ using LINGYUN.Abp.AspNetCore.MultiTenancy; using LINGYUN.Abp.Identity; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement; -using LINGYUN.Abp.OpenIddict.AspNetCore.Session; using LINGYUN.Abp.OpenIddict.Impersonation; -using LINGYUN.Abp.OpenIddict.LinkUser; -using LINGYUN.Abp.OpenIddict.Portal; -using LINGYUN.Abp.OpenIddict.Sms; -using LINGYUN.Abp.OpenIddict.WeChat; using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; -using LINGYUN.Abp.WeChat.Work; using LINGYUN.Abp.Wrapper; using LY.MicroService.AuthServer.Ui.Branding; using Medallion.Threading; @@ -292,16 +286,6 @@ public partial class AuthServerModule options.IsDynamicClaimsEnabled = true; options.IsRemoteRefreshEnabled = false; }); - - Configure(options => - { - options.PersistentSessionGrantTypes.Add(SmsTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(PortalTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(LinkUserTokenExtensionGrantConsts.GrantType); - options.PersistentSessionGrantTypes.Add(WeChatTokenExtensionGrantConsts.OfficialGrantType); - options.PersistentSessionGrantTypes.Add(WeChatTokenExtensionGrantConsts.MiniProgramGrantType); - options.PersistentSessionGrantTypes.Add(AbpWeChatWorkGlobalConsts.GrantType); - }); } private void ConfigureVirtualFileSystem() { diff --git a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs index ec5ebd0c1..7627d7ee7 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs @@ -1,10 +1,12 @@ using LINGYUN.Abp.Account; using LINGYUN.Abp.Account.Web.OAuth; using LINGYUN.Abp.Account.Web.OpenIddict; +using LINGYUN.Abp.Account.Web.TencentCaptcha; using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.MultiTenancy; using LINGYUN.Abp.AspNetCore.Mvc.UI.MultiTenancy; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.BlobStoring.BlobManagement; using LINGYUN.Abp.Data.DbMigrator; @@ -14,11 +16,8 @@ using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.Exporter.MiniSoftware; using LINGYUN.Abp.Gdpr; using LINGYUN.Abp.Gdpr.Web; -using LINGYUN.Abp.Identity.AspNetCore.Session; using LINGYUN.Abp.Identity.OrganizaztionUnits; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; -using LINGYUN.Abp.OpenIddict.AspNetCore.Session; using LINGYUN.Abp.OpenIddict.Impersonation; using LINGYUN.Abp.OpenIddict.LinkUser; using LINGYUN.Abp.OpenIddict.Portal; @@ -52,6 +51,10 @@ namespace LY.MicroService.AuthServer; typeof(AbpAspNetCoreSerilogModule), typeof(AbpAccountApplicationModule), typeof(AbpAccountHttpApiModule), + // 使用 LazyCaptcha 验证码组件 + // typeof(AbpAccountWebLazyCaptchaModule), + // 使用 腾讯云天御 验证码组件, 需配置好腾讯云相关参数 + // typeof(AbpAccountWebTencentCaptchaModule), typeof(AbpAccountWebOpenIddictModule), typeof(AbpAccountWebOAuthModule), typeof(AbpBlobStoringBlobManagementModule), @@ -61,9 +64,6 @@ namespace LY.MicroService.AuthServer; typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule), typeof(AbpAutofacModule), typeof(AbpCachingStackExchangeRedisModule), - typeof(AbpIdentityAspNetCoreSessionModule), - typeof(AbpOpenIddictAspNetCoreSessionModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpOpenIddictSmsModule), typeof(AbpOpenIddictWeChatModule), typeof(AbpOpenIddictLinkUserModule), @@ -76,6 +76,7 @@ namespace LY.MicroService.AuthServer; typeof(AbpDataDbMigratorModule), typeof(AbpAuditLoggingElasticsearchModule), // 放在 AbpIdentity 模块之后,避免被覆盖 typeof(AbpLocalizationCultureMapModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcUiMultiTenancyModule), typeof(AbpAspNetCoreMultiTenancyModule), typeof(AbpAspNetCoreMvcWrapperModule), @@ -156,7 +157,6 @@ public partial class AuthServerModule : AbpModule app.UseAuthentication(); app.UseAbpOpenIddictValidation(); app.UseMultiTenancy(); - app.UseAbpSession(); app.UseUnitOfWork(); app.UseDynamicClaims(); app.UseAuthorization(); 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 9d73b9288..d0f35e5b6 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj +++ b/aspnet-core/services/LY.MicroService.AuthServer/LY.MicroService.AuthServer.csproj @@ -45,6 +45,7 @@ + @@ -64,16 +65,15 @@ + + - - - diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs index 9788fc44a..81505422d 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs @@ -1,6 +1,7 @@ using LINGYUN.Abp.Aliyun.SettingManagement; using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.Auditing; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.BlobManagement.SettingManagement; @@ -16,7 +17,6 @@ using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.FeatureManagement; using LINGYUN.Abp.FeatureManagement.HttpApi; using LINGYUN.Abp.Identity.EntityFrameworkCore; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.Logging.Serilog.Elasticsearch; @@ -105,12 +105,8 @@ namespace LY.MicroService.BackendAdmin; typeof(AbpFeatureManagementEntityFrameworkCoreModule), typeof(AbpLocalizationManagementEntityFrameworkCoreModule), typeof(AbpTextTemplatingEntityFrameworkCoreModule), - // 重写模板引擎支持外部本地化 typeof(AbpTextTemplatingScribanModule), - - typeof(AbpIdentitySessionAspNetCoreModule), - typeof(BackendAdminMigrationsEntityFrameworkCoreModule), typeof(AbpDataDbMigratorModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule), @@ -122,6 +118,7 @@ namespace LY.MicroService.BackendAdmin; typeof(AbpEmailingPlatformModule), typeof(AbpCachingStackExchangeRedisModule), typeof(AbpLocalizationCultureMapModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), @@ -188,8 +185,6 @@ public partial class BackendAdminHttpApiHostModule : AbpModule app.UseJwtTokenMiddleware(); // 多租户 app.UseMultiTenancy(); - // 会话 - app.UseAbpSession(); // jwt app.UseDynamicClaims(); // 授权 diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj index 43847c52d..db74ae4c8 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/LY.MicroService.BackendAdmin.HttpApi.Host.csproj @@ -49,6 +49,7 @@ + @@ -77,7 +78,6 @@ - diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj index 0ee5c1e64..9540c8cc9 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LY.MicroService.LocalizationManagement.HttpApi.Host.csproj @@ -40,6 +40,7 @@ + @@ -55,7 +56,6 @@ - diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs index c6a713e39..e033f745a 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.Claims.Mapping; @@ -8,7 +9,6 @@ using LINGYUN.Abp.Dynamic.Definitions; using LINGYUN.Abp.Emailing.Platform; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Emailing; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; @@ -58,12 +58,12 @@ namespace LY.MicroService.LocalizationManagement; typeof(AbpCAPEventBusModule), typeof(AbpCachingStackExchangeRedisModule), typeof(AbpLocalizationCultureMapModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpTelemetryOpenTelemetryModule), typeof(AbpTelemetrySkyWalkingModule), typeof(AbpHttpClientModule), typeof(AbpSmsPlatformModule), typeof(AbpEmailingPlatformModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), @@ -129,7 +129,6 @@ public partial class LocalizationManagementHttpApiHostModule : AbpModule // 多租户 app.UseMultiTenancy(); // 会话 - app.UseAbpSession(); app.UseDynamicClaims(); // 授权 app.UseAuthorization(); diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj index 91f1f2bf3..105bf59c9 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/LY.MicroService.PlatformManagement.HttpApi.Host.csproj @@ -45,6 +45,7 @@ + @@ -64,7 +65,6 @@ - diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs index 6f168a4f9..eb118b2ba 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.BlobManagement; @@ -16,7 +17,6 @@ using LINGYUN.Abp.Dynamic.Definitions; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.Features.LimitValidation.Redis; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.Notifications; @@ -102,12 +102,12 @@ namespace LY.MicroService.PlatformManagement; // typeof(AbpFeaturesValidationRedisClientModule),// 当需要客户端特性限制时取消注释此模块 typeof(AbpCachingStackExchangeRedisModule), typeof(AbpLocalizationCultureMapModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpTelemetryOpenTelemetryModule), typeof(AbpTelemetrySkyWalkingModule), typeof(AbpHttpClientModule), typeof(AbpMailKitModule), typeof(AbpAliyunSmsModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpClaimsMappingModule), typeof(AbpAspNetCoreHttpOverridesModule), @@ -191,7 +191,6 @@ public partial class PlatformManagementHttpApiHostModule : AbpModule // 多租户 app.UseMultiTenancy(); // 会话 - app.UseAbpSession(); app.UseDynamicClaims(); // 授权 app.UseAuthorization(); diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj index 26d2502c3..0010ec448 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/LY.MicroService.RealtimeMessage.HttpApi.Host.csproj @@ -47,6 +47,7 @@ + @@ -68,7 +69,6 @@ - diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs index c1deb04c3..10c4263dd 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.BackgroundTasks.DistributedLocking; @@ -13,7 +14,6 @@ using LINGYUN.Abp.ExceptionHandling.Notifications; using LINGYUN.Abp.Features.LimitValidation.Redis; using LINGYUN.Abp.Identity.EntityFrameworkCore; using LINGYUN.Abp.Identity.Notifications; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Identity.WeChat; using LINGYUN.Abp.Identity.WeChat.Work; using LINGYUN.Abp.IM.SignalR; @@ -117,13 +117,13 @@ namespace LY.MicroService.RealtimeMessage; typeof(AbpFeaturesValidationRedisModule), typeof(AbpCachingStackExchangeRedisModule), typeof(AbpLocalizationCultureMapModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpEmailingPlatformModule), typeof(AbpSmsPlatformModule), typeof(AbpHttpClientModule), typeof(AbpClaimsMappingModule), typeof(AbpTelemetryOpenTelemetryModule), typeof(AbpTelemetrySkyWalkingModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), @@ -191,7 +191,6 @@ public partial class RealtimeMessageHttpApiHostModule : AbpModule // 多租户 app.UseMultiTenancy(); // 会话 - app.UseAbpSession(); app.UseDynamicClaims(); // 授权 app.UseAuthorization(); diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj index 0a7da1a61..5fd2d0d83 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj @@ -48,6 +48,7 @@ + diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs index 58f216176..f2d2f2668 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.BackgroundTasks.DistributedLocking; @@ -87,6 +88,7 @@ namespace LY.MicroService.TaskManagement; typeof(AbpAspNetCoreMvcModule), typeof(AbpSwashbuckleModule), typeof(AbpLocalizationCultureMapModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj index c013775fe..34e35e0df 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/LY.MicroService.WebhooksManagement.HttpApi.Host.csproj @@ -39,6 +39,7 @@ + @@ -57,7 +58,6 @@ - diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs index c129bce1a..662d9cf8d 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.BackgroundTasks.DistributedLocking; @@ -11,7 +12,6 @@ using LINGYUN.Abp.Emailing.Platform; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.Http.Client.Wrapper; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.Quartz.MySqlInstaller; using LINGYUN.Abp.Saas.EntityFrameworkCore; @@ -84,10 +84,10 @@ namespace LY.MicroService.WebhooksManagement; typeof(AbpSmsPlatformModule), typeof(AbpTelemetryOpenTelemetryModule), typeof(AbpTelemetrySkyWalkingModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpAutofacModule) )] public partial class WebhooksManagementHttpApiHostModule : AbpModule @@ -145,7 +145,6 @@ public partial class WebhooksManagementHttpApiHostModule : AbpModule app.UseAuthentication(); app.UseJwtTokenMiddleware(); app.UseMultiTenancy(); - app.UseAbpSession(); app.UseDynamicClaims(); app.UseAuthorization(); app.UseSwagger(); diff --git a/aspnet-core/services/LY.MicroService.WechatManagement.HttpApi.Host/LY.MicroService.WechatManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.WechatManagement.HttpApi.Host/LY.MicroService.WechatManagement.HttpApi.Host.csproj index 9600daaa7..f237b73f9 100644 --- a/aspnet-core/services/LY.MicroService.WechatManagement.HttpApi.Host/LY.MicroService.WechatManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.WechatManagement.HttpApi.Host/LY.MicroService.WechatManagement.HttpApi.Host.csproj @@ -41,6 +41,7 @@ + @@ -69,7 +70,6 @@ - diff --git a/aspnet-core/services/LY.MicroService.WechatManagement.HttpApi.Host/WechatManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WechatManagement.HttpApi.Host/WechatManagementHttpApiHostModule.cs index 695de72fe..dd21f1383 100644 --- a/aspnet-core/services/LY.MicroService.WechatManagement.HttpApi.Host/WechatManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.WechatManagement.HttpApi.Host/WechatManagementHttpApiHostModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.Claims.Mapping; @@ -8,7 +9,6 @@ using LINGYUN.Abp.EntityFrameworkCore.MySQL; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.Http.Client.Wrapper; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Identity.WeChat.Work; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.Saas.EntityFrameworkCore; @@ -82,10 +82,10 @@ namespace LY.MicroService.WechatManagement; typeof(AbpClaimsMappingModule), typeof(AbpTelemetryOpenTelemetryModule), typeof(AbpTelemetrySkyWalkingModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpAutofacModule) )] public partial class WechatManagementHttpApiHostModule : AbpModule @@ -142,7 +142,6 @@ public partial class WechatManagementHttpApiHostModule : AbpModule app.UseAuthentication(); app.UseJwtTokenMiddleware(); app.UseMultiTenancy(); - app.UseAbpSession(); app.UseDynamicClaims(); app.UseAuthorization(); app.UseSwagger(); diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj index 1d9180042..48dd57e1d 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj @@ -49,6 +49,7 @@ + @@ -70,7 +71,6 @@ - diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs index b315946a3..77defd31d 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs @@ -1,5 +1,6 @@ using LINGYUN.Abp.AspNetCore.HttpOverrides; using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.AuditLogging.Elasticsearch; using LINGYUN.Abp.Authorization.OrganizationUnits; using LINGYUN.Abp.BackgroundTasks.DistributedLocking; @@ -15,7 +16,6 @@ using LINGYUN.Abp.Elsa.Notifications; using LINGYUN.Abp.EventBus.CAP; using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.Http.Client.Wrapper; -using LINGYUN.Abp.Identity.Session.AspNetCore; using LINGYUN.Abp.Localization.CultureMap; using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; using LINGYUN.Abp.Quartz.MySqlInstaller; @@ -86,10 +86,10 @@ namespace LY.MicroService.WorkflowManagement; typeof(AbpClaimsMappingModule), typeof(AbpTelemetryOpenTelemetryModule), typeof(AbpTelemetrySkyWalkingModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcNewtonsoftModule), typeof(AbpAspNetCoreHttpOverridesModule), typeof(AbpDynamicDefinitionsModule), - typeof(AbpIdentitySessionAspNetCoreModule), typeof(AbpAutofacModule) )] public partial class WorkflowManagementHttpApiHostModule : AbpModule @@ -146,7 +146,6 @@ public partial class WorkflowManagementHttpApiHostModule : AbpModule app.UseAuthentication(); app.UseJwtTokenMiddleware(); app.UseMultiTenancy(); - app.UseAbpSession(); app.UseDynamicClaims(); app.UseAuthorization(); app.UseSwagger(); diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/LINGYUN.MicroService.Internal.ApiGateway.slnx b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/LINGYUN.MicroService.Internal.ApiGateway.slnx index d7999a6d4..4ea5ef1d6 100644 --- a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/LINGYUN.MicroService.Internal.ApiGateway.slnx +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/LINGYUN.MicroService.Internal.ApiGateway.slnx @@ -14,10 +14,6 @@ - - - - @@ -32,6 +28,10 @@
+ + + + diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/LINGYUN.MicroService.OpenApi.Gateway.csproj b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/LINGYUN.MicroService.OpenApi.Gateway.csproj index f70021296..22d12a145 100644 --- a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/LINGYUN.MicroService.OpenApi.Gateway.csproj +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/LINGYUN.MicroService.OpenApi.Gateway.csproj @@ -5,7 +5,7 @@ net10.0 LINGYUN.MicroService.Internal.Gateway latest - enable + enable @@ -32,13 +32,13 @@ + - diff --git a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/OpenApiGatewayModule.cs b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/OpenApiGatewayModule.cs index 0c88f173f..1dbabe611 100644 --- a/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/OpenApiGatewayModule.cs +++ b/gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.OpenApi.Gateway/OpenApiGatewayModule.cs @@ -1,5 +1,5 @@ using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; -using LINGYUN.Abp.Identity.Session.AspNetCore; +using LINGYUN.Abp.AspNetCore.Session; using LINGYUN.Abp.OpenApi.Authorization; using LINGYUN.Abp.Serilog.Enrichers.Application; using LINGYUN.Abp.Serilog.Enrichers.UniqueId; @@ -34,10 +34,10 @@ namespace LINGYUN.MicroService.OpenApi.Gateway; typeof(AbpDataModule), typeof(AbpSwashbuckleModule), typeof(AbpAspNetCoreSerilogModule), + typeof(AbpAspNetCoreSessionModule), typeof(AbpAspNetCoreMvcWrapperModule), typeof(AbpOpenApiAuthorizationModule), - typeof(AbpCachingStackExchangeRedisModule), - typeof(AbpIdentitySessionAspNetCoreModule) + typeof(AbpCachingStackExchangeRedisModule) )] public class OpenApiGatewayModule : AbpModule { @@ -177,8 +177,6 @@ public class OpenApiGatewayModule : AbpModule app.UseOpenApiAuthorization(); // 认证 app.UseAuthentication(); - // 会话 - app.UseAbpSession(); // 令牌 app.UseDynamicClaims(); // 授权