diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/AllowAnonymousIdentitySessionChecker.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/AllowAnonymousIdentitySessionChecker.cs new file mode 100644 index 000000000..bac6f1872 --- /dev/null +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/LINGYUN/Abp/Identity/Session/AllowAnonymousIdentitySessionChecker.cs @@ -0,0 +1,12 @@ +using System.Security.Claims; +using System.Threading; +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Identity.Session; +public class AllowAnonymousIdentitySessionChecker : IIdentitySessionChecker +{ + public Task ValidateSessionAsync(ClaimsPrincipal claimsPrincipal, CancellationToken cancellationToken = default) + { + return Task.FromResult(true); + } +} diff --git a/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/Microsoft/Extensions/DependencyInjection/IdentitySessionServiceCollectionExtensions.cs b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/Microsoft/Extensions/DependencyInjection/IdentitySessionServiceCollectionExtensions.cs new file mode 100644 index 000000000..2e7154f03 --- /dev/null +++ b/aspnet-core/modules/identity/LINGYUN.Abp.Identity.Session/Microsoft/Extensions/DependencyInjection/IdentitySessionServiceCollectionExtensions.cs @@ -0,0 +1,22 @@ +using LINGYUN.Abp.Identity.Session; +using Microsoft.Extensions.DependencyInjection.Extensions; + +namespace Microsoft.Extensions.DependencyInjection; +public static class IdentitySessionServiceCollectionExtensions +{ + /// + /// 允许任意会话 + /// + /// + /// 某些场景下可能缓存配置不同,可不检查会话缓存 + /// + /// + /// + public static IServiceCollection AddAlwaysAllowSession(this IServiceCollection services) + { + services.Replace( + ServiceDescriptor.Singleton()); + + return services; + } +}