Skip to content

Commit f9c2f8a

Browse files
committed
feat(identity): Add anonymous sessions
1 parent 512d919 commit f9c2f8a

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Security.Claims;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
5+
namespace LINGYUN.Abp.Identity.Session;
6+
public class AllowAnonymousIdentitySessionChecker : IIdentitySessionChecker
7+
{
8+
public Task<bool> ValidateSessionAsync(ClaimsPrincipal claimsPrincipal, CancellationToken cancellationToken = default)
9+
{
10+
return Task.FromResult(true);
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using LINGYUN.Abp.Identity.Session;
2+
using Microsoft.Extensions.DependencyInjection.Extensions;
3+
4+
namespace Microsoft.Extensions.DependencyInjection;
5+
public static class IdentitySessionServiceCollectionExtensions
6+
{
7+
/// <summary>
8+
/// 允许任意会话
9+
/// </summary>
10+
/// <remarks>
11+
/// 某些场景下可能缓存配置不同,可不检查会话缓存
12+
/// </remarks>
13+
/// <param name="services"></param>
14+
/// <returns></returns>
15+
public static IServiceCollection AddAlwaysAllowSession(this IServiceCollection services)
16+
{
17+
services.Replace(
18+
ServiceDescriptor.Singleton<IIdentitySessionChecker, AllowAnonymousIdentitySessionChecker>());
19+
20+
return services;
21+
}
22+
}

0 commit comments

Comments
 (0)