diff --git a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs index ff4fa9f5f..5defc7414 100644 --- a/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs +++ b/aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/AccountAppService.cs @@ -95,7 +95,7 @@ namespace LINGYUN.Abp.Account var userLogin = new UserLoginInfo(AbpWeChatMiniProgramConsts.ProviderName, wehchatOpenId.OpenId, AbpWeChatGlobalConsts.DisplayName); (await UserManager.AddLoginAsync(user, userLogin)).CheckErrors(); - await CurrentUnitOfWork.SaveChangesAsync(); + await CurrentUnitOfWork.CompleteAsync(); } public virtual async Task SendPhoneRegisterCodeAsync(SendPhoneRegisterCodeDto input) @@ -168,7 +168,7 @@ namespace LINGYUN.Abp.Account await SecurityTokenCache.RemoveAsync(securityTokenCacheKey); - await CurrentUnitOfWork.SaveChangesAsync(); + await CurrentUnitOfWork.CompleteAsync(); return; } @@ -244,7 +244,7 @@ namespace LINGYUN.Abp.Account // 移除缓存项 await SecurityTokenCache.RemoveAsync(securityTokenCacheKey); - await CurrentUnitOfWork.SaveChangesAsync(); + await CurrentUnitOfWork.CompleteAsync(); } public virtual async Task SendPhoneSigninCodeAsync(SendPhoneSigninCodeDto input) diff --git a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.Configure.cs b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.Configure.cs index c7644b482..666a6922c 100644 --- a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.Configure.cs +++ b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.Configure.cs @@ -100,9 +100,9 @@ namespace AuthServer.Host // 最好统一命名,不然某个缓存变动其他应用服务有例外发生 options.KeyPrefix = "LINGYUN.Abp.Application"; // 滑动过期30天 - options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); + options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30d); // 绝对过期60天 - options.GlobalCacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(60); + options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddDays(60d); }); Configure(options => @@ -175,8 +175,11 @@ namespace AuthServer.Host var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); services .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "AuthServer-Protection-Keys"); + .SetApplicationName("LINGYUN.Abp.Application") + .PersistKeysToStackExchangeRedis(redis, "LINGYUN.Abp.Application:DataProtection:Protection-Keys"); } + + services.AddSameSiteCookiePolicy(); } private void ConfigureMultiTenancy(IConfiguration configuration) { diff --git a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs index f83134d1c..9708c11a7 100644 --- a/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs +++ b/aspnet-core/services/account/AuthServer.Host/AuthIdentityServerModule.cs @@ -92,10 +92,6 @@ namespace AuthServer.Host ConfigureMultiTenancy(configuration); ConfigureCors(context.Services, configuration); ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); - - context.Services.ConfigureNonBreakingSameSiteCookies(); - - } public override void OnApplicationInitialization(ApplicationInitializationContext context) diff --git a/aspnet-core/services/account/AuthServer.Host/Microsoft/Extensions/DependencyInjection/SameSiteCookiesServiceCollectionExtensions.cs b/aspnet-core/services/account/AuthServer.Host/Microsoft/Extensions/DependencyInjection/SameSiteCookiesServiceCollectionExtensions.cs index 9847bd905..a408c6bf9 100644 --- a/aspnet-core/services/account/AuthServer.Host/Microsoft/Extensions/DependencyInjection/SameSiteCookiesServiceCollectionExtensions.cs +++ b/aspnet-core/services/account/AuthServer.Host/Microsoft/Extensions/DependencyInjection/SameSiteCookiesServiceCollectionExtensions.cs @@ -1,163 +1,70 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using System; - -/* - * See: https://community.abp.io/articles/patch-for-chrome-login-issue-identityserver4-samesite-cookie-problem-weypwp3n - */ - -namespace Microsoft.Extensions.DependencyInjection -{ - public static class SameSiteCookiesServiceCollectionExtensions - { - /// - /// -1 defines the unspecified value, which tells ASPNET Core to NOT - /// send the SameSite attribute. With ASPNET Core 3.1 the - /// enum will have a definition for - /// Unspecified. - /// - private const SameSiteMode Unspecified = (SameSiteMode)(-1); - - /// - /// Configures a cookie policy to properly set the SameSite attribute - /// for Browsers that handle unknown values as Strict. Ensure that you - /// add the - /// into the pipeline before sending any cookies! - /// - /// - /// Minimum ASPNET Core Version required for this code: - /// - 2.1.14 - /// - 2.2.8 - /// - 3.0.1 - /// - 3.1.0-preview1 - /// Starting with version 80 of Chrome (to be released in February 2020) - /// cookies with NO SameSite attribute are treated as SameSite=Lax. - /// In order to always get the cookies send they need to be set to - /// SameSite=None. But since the current standard only defines Lax and - /// Strict as valid values there are some browsers that treat invalid - /// values as SameSite=Strict. We therefore need to check the browser - /// and either send SameSite=None or prevent the sending of SameSite=None. - /// Relevant links: - /// - https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1 - /// - https://tools.ietf.org/html/draft-west-cookie-incrementalism-00 - /// - https://www.chromium.org/updates/same-site - /// - https://devblogs.microsoft.com/aspnet/upcoming-samesite-cookie-changes-in-asp-net-and-asp-net-core/ - /// - https://bugs.webkit.org/show_bug.cgi?id=198181 - /// - /// The service collection to register into. - /// The modified . - public static IServiceCollection ConfigureNonBreakingSameSiteCookies(this IServiceCollection services) - { - services.Configure(options => - { - options.MinimumSameSitePolicy = Unspecified; - options.OnAppendCookie = cookieContext => - CheckSameSite(cookieContext.Context, cookieContext.CookieOptions); - options.OnDeleteCookie = cookieContext => - CheckSameSite(cookieContext.Context, cookieContext.CookieOptions); - }); - - return services; - } - - private static void CheckSameSite(HttpContext httpContext, CookieOptions options) - { - if (options.SameSite == SameSiteMode.None) - { - var userAgent = httpContext.Request.Headers["User-Agent"].ToString(); - - if (DisallowsSameSiteNone(userAgent)) - { - options.SameSite = Unspecified; - } - } - } - - /// - /// Checks if the UserAgent is known to interpret an unknown value as Strict. - /// For those the property should be - /// set to . - /// - /// - /// This code is taken from Microsoft: - /// https://devblogs.microsoft.com/aspnet/upcoming-samesite-cookie-changes-in-asp-net-and-asp-net-core/ - /// - /// The user agent string to check. - /// Whether the specified user agent (browser) accepts SameSite=None or not. - private static bool DisallowsSameSiteNone(string userAgent) - { - // Cover all iOS based browsers here. This includes: - // - Safari on iOS 12 for iPhone, iPod Touch, iPad - // - WkWebview on iOS 12 for iPhone, iPod Touch, iPad - // - Chrome on iOS 12 for iPhone, iPod Touch, iPad - // All of which are broken by SameSite=None, because they use the - // iOS networking stack. - // Notes from Thinktecture: - // Regarding https://caniuse.com/#search=samesite iOS versions lower - // than 12 are not supporting SameSite at all. Starting with version 13 - // unknown values are NOT treated as strict anymore. Therefore we only - // need to check version 12. - if (userAgent.Contains("CPU iPhone OS 12") - || userAgent.Contains("iPad; CPU OS 12")) - { - return true; - } - - // Cover Mac OS X based browsers that use the Mac OS networking stack. - // This includes: - // - Safari on Mac OS X. - // This does not include: - // - Chrome on Mac OS X - // because they do not use the Mac OS networking stack. - // Notes from Thinktecture: - // Regarding https://caniuse.com/#search=samesite MacOS X versions lower - // than 10.14 are not supporting SameSite at all. Starting with version - // 10.15 unknown values are NOT treated as strict anymore. Therefore we - // only need to check version 10.14. - if (userAgent.Contains("Safari") - && userAgent.Contains("Macintosh; Intel Mac OS X 10_14") - && userAgent.Contains("Version/")) - { - return true; - } - - // Cover Chrome 50-69, because some versions are broken by SameSite=None - // and none in this range require it. - // Note: this covers some pre-Chromium Edge versions, - // but pre-Chromium Edge does not require SameSite=None. - // Notes from Thinktecture: - // We can not validate this assumption, but we trust Microsofts - // evaluation. And overall not sending a SameSite value equals to the same - // behavior as SameSite=None for these old versions anyways. - if (userAgent.Contains("Chrome/5") || userAgent.Contains("Chrome/6")) - { - return true; - } - - if (GetChromeVersion(userAgent) >= 80) - { - return true; - } - - return false; - } - - private static int GetChromeVersion(string userAgent) - { - try - { - string version = "0"; - var chromeAgents = userAgent.Split("Chrome/"); - if (chromeAgents.Length > 1 && chromeAgents[1].Split('.').Length > 0) - { - version = chromeAgents[1].Split('.')[0]; - } - return Convert.ToInt32(version); - } - catch (Exception) - { - return 0; - } - } - } +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; + +namespace Microsoft.Extensions.DependencyInjection +{ + public static class SameSiteCookiesServiceCollectionExtensions + { + public static IServiceCollection AddSameSiteCookiePolicy(this IServiceCollection services) + { + services.Configure(options => + { + options.MinimumSameSitePolicy = SameSiteMode.Unspecified; + options.OnAppendCookie = cookieContext => + CheckSameSite(cookieContext.Context, cookieContext.CookieOptions); + options.OnDeleteCookie = cookieContext => + CheckSameSite(cookieContext.Context, cookieContext.CookieOptions); + }); + + return services; + } + + private static void CheckSameSite(HttpContext httpContext, CookieOptions options) + { + if (options.SameSite == SameSiteMode.None) + { + var userAgent = httpContext.Request.Headers["User-Agent"].ToString(); + if (!httpContext.Request.IsHttps || DisallowsSameSiteNone(userAgent)) + { + // For .NET Core < 3.1 set SameSite = (SameSiteMode)(-1) + options.SameSite = SameSiteMode.Unspecified; + } + } + } + + private static bool DisallowsSameSiteNone(string userAgent) + { + // Cover all iOS based browsers here. This includes: + // - Safari on iOS 12 for iPhone, iPod Touch, iPad + // - WkWebview on iOS 12 for iPhone, iPod Touch, iPad + // - Chrome on iOS 12 for iPhone, iPod Touch, iPad + // All of which are broken by SameSite=None, because they use the iOS networking stack + if (userAgent.Contains("CPU iPhone OS 12") || userAgent.Contains("iPad; CPU OS 12")) + { + return true; + } + + // Cover Mac OS X based browsers that use the Mac OS networking stack. This includes: + // - Safari on Mac OS X. + // This does not include: + // - Chrome on Mac OS X + // Because they do not use the Mac OS networking stack. + if (userAgent.Contains("Macintosh; Intel Mac OS X 10_14") && + userAgent.Contains("Version/") && userAgent.Contains("Safari")) + { + return true; + } + + // Cover Chrome 50-69, because some versions are broken by SameSite=None, + // and none in this range require it. + // Note: this covers some pre-Chromium Edge versions, + // but pre-Chromium Edge does not require SameSite=None. + if (userAgent.Contains("Chrome/5") || userAgent.Contains("Chrome/6")) + { + return true; + } + + return false; + } + } } \ No newline at end of file diff --git a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.Configure.cs b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.Configure.cs index 089f39072..1af93cd1d 100644 --- a/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.Configure.cs +++ b/aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/BackendAdminHostModule.Configure.cs @@ -114,9 +114,9 @@ namespace LINGYUN.Abp.BackendAdmin // 最好统一命名,不然某个缓存变动其他应用服务有例外发生 options.KeyPrefix = "LINGYUN.Abp.Application"; // 滑动过期30天 - options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); + options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30d); // 绝对过期60天 - options.GlobalCacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(60); + options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddDays(60d); }); Configure(options => @@ -262,7 +262,8 @@ namespace LINGYUN.Abp.BackendAdmin var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); services .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "BackendAdmin-Protection-Keys"); + .SetApplicationName("LINGYUN.Abp.Application") + .PersistKeysToStackExchangeRedis(redis, "LINGYUN.Abp.Application:DataProtection:Protection-Keys"); } } } diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.Configure.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.Configure.cs index 3e361ebb9..6b606bcbd 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.Configure.cs +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.Host/ApiGatewayHostModule.Configure.cs @@ -153,9 +153,9 @@ namespace LINGYUN.ApiGateway // 最好统一命名,不然某个缓存变动其他应用服务有例外发生 options.KeyPrefix = "LINGYUN.Abp.Application"; // 滑动过期30天 - options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); + options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30d); // 绝对过期60天 - options.GlobalCacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(60); + options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddDays(60d); }); Configure(options => @@ -217,7 +217,8 @@ namespace LINGYUN.ApiGateway var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); services .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "ApiGatewayHost-Protection-Keys"); + .SetApplicationName("LINGYUN.Abp.Application") + .PersistKeysToStackExchangeRedis(redis, "LINGYUN.Abp.Application:DataProtection:Protection-Keys"); } } } diff --git a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.Configure.cs b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.Configure.cs index c924bf09f..2ff440562 100644 --- a/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/apigateway/LINGYUN.ApiGateway.HttpApi.Host/ApiGatewayHttpApiHostModule.Configure.cs @@ -78,9 +78,9 @@ namespace LINGYUN.ApiGateway // 最好统一命名,不然某个缓存变动其他应用服务有例外发生 options.KeyPrefix = "LINGYUN.Abp.Application"; // 滑动过期30天 - options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); + options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30d); // 绝对过期60天 - options.GlobalCacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromDays(60); + options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddDays(60d); }); Configure(options => @@ -182,7 +182,8 @@ namespace LINGYUN.ApiGateway var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); services .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "ApiGatewayAdmin-Protection-Keys"); + .SetApplicationName("LINGYUN.Abp.Application") + .PersistKeysToStackExchangeRedis(redis, "LINGYUN.Abp.Application:DataProtection:Protection-Keys"); } } } diff --git a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.Configure.cs b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.Configure.cs index d29fb3913..62ed63cba 100644 --- a/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/AbpIdentityServerAdminHttpApiHostModule.Configure.cs @@ -138,9 +138,9 @@ namespace LINGYUN.Abp.IdentityServer4 // 最好统一命名,不然某个缓存变动其他应用服务有例外发生 options.KeyPrefix = "LINGYUN.Abp.Application"; // 滑动过期30天 - options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); + options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30d); // 绝对过期60天 - options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(60); + options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddDays(60d); }); Configure(options => @@ -250,7 +250,8 @@ namespace LINGYUN.Abp.IdentityServer4 var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); services .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "IDS-Admin-Protection-Keys"); + .SetApplicationName("LINGYUN.Abp.Application") + .PersistKeysToStackExchangeRedis(redis, "LINGYUN.Abp.Application:DataProtection:Protection-Keys"); } } } diff --git a/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/AbpLocalizationManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/AbpLocalizationManagementHttpApiHostModule.Configure.cs index e0c0bba1b..c0acbed65 100644 --- a/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/AbpLocalizationManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/localization/LINGYUN.Abp.LocalizationManagement.HttpApi.Host/AbpLocalizationManagementHttpApiHostModule.Configure.cs @@ -112,9 +112,9 @@ namespace LINGYUN.Abp.LocalizationManagement // 最好统一命名,不然某个缓存变动其他应用服务有例外发生 options.KeyPrefix = "LINGYUN.Abp.Application"; // 滑动过期30天 - options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); + options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30d); // 绝对过期60天 - options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(60); + options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddDays(60d); }); Configure(options => @@ -201,7 +201,8 @@ namespace LINGYUN.Abp.LocalizationManagement var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); services .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "Localization-Protection-Keys"); + .SetApplicationName("LINGYUN.Abp.Application") + .PersistKeysToStackExchangeRedis(redis, "LINGYUN.Abp.Application:DataProtection:Protection-Keys"); } } } diff --git a/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.Configure.cs b/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.Configure.cs index 90c09acc3..308c5b1b3 100644 --- a/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/messages/LINGYUN.Abp.MessageService.HttpApi.Host/AbpMessageServiceHttpApiHostModule.Configure.cs @@ -114,9 +114,9 @@ namespace LINGYUN.Abp.MessageService // 最好统一命名,不然某个缓存变动其他应用服务有例外发生 options.KeyPrefix = "LINGYUN.Abp.Application"; // 滑动过期30天 - options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); + options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30d); // 绝对过期60天 - options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(60); + options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddDays(60d); }); Configure(options => @@ -242,7 +242,8 @@ namespace LINGYUN.Abp.MessageService var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); services .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "MessageService-Protection-Keys"); + .SetApplicationName("LINGYUN.Abp.Application") + .PersistKeysToStackExchangeRedis(redis, "LINGYUN.Abp.Application:DataProtection:Protection-Keys"); } } } diff --git a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.Configure.cs b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.Configure.cs index fb867820e..b98d43303 100644 --- a/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/platform/LINGYUN.Platform.HttpApi.Host/AppPlatformHttpApiHostModule.Configure.cs @@ -144,9 +144,9 @@ namespace LINGYUN.Platform // 最好统一命名,不然某个缓存变动其他应用服务有例外发生 options.KeyPrefix = "LINGYUN.Abp.Application"; // 滑动过期30天 - options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); + options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30d); // 绝对过期60天 - options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(60); + options.GlobalCacheEntryOptions.AbsoluteExpiration = DateTimeOffset.Now.AddDays(60d); }); Configure(options => @@ -246,7 +246,8 @@ namespace LINGYUN.Platform var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); services .AddDataProtection() - .PersistKeysToStackExchangeRedis(redis, "Platform-Protection-Keys"); + .SetApplicationName("LINGYUN.Abp.Application") + .PersistKeysToStackExchangeRedis(redis, "LINGYUN.Abp.Application:DataProtection:Protection-Keys"); } } }