Browse Source

feat: Add an IP region to the identity session

pull/1101/head
colin 12 months ago
parent
commit
0779abd39f
  1. 2
      aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.EntityFrameworkCore/LINGYUN/Abp/AuditLogging/EntityFrameworkCore/SecurityLogManager.cs
  2. 2
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IIdentitySessionStore.cs
  3. 1
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionManager.cs
  4. 6
      aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionStore.cs

2
aspnet-core/framework/auditing/LINGYUN.Abp.AuditLogging.EntityFrameworkCore/LINGYUN/Abp/AuditLogging/EntityFrameworkCore/SecurityLogManager.cs

@ -118,6 +118,7 @@ public class SecurityLogManager : ISecurityLogManager, ITransientDependency
userName,
clientId,
correlationId,
clientIpAddress,
includeDetails,
cancellationToken);
@ -148,6 +149,7 @@ public class SecurityLogManager : ISecurityLogManager, ITransientDependency
userName,
clientId,
correlationId,
clientIpAddress,
cancellationToken);
}
}

2
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IIdentitySessionStore.cs

@ -21,6 +21,7 @@ public interface IIdentitySessionStore
/// <param name="ipAddresses">ip地址</param>
/// <param name="signedIn">登录时间</param>
/// <param name="lastAccessed">上次访问时间</param>
/// <param name="ipRegion">IP地域</param>
/// <param name="tenantId">租户id</param>
/// <param name="cancellationToken"></param>
/// <returns>创建完成的 <seealso cref="IdentitySession"/></returns>
@ -33,6 +34,7 @@ public interface IIdentitySessionStore
string ipAddresses,
DateTime signedIn,
DateTime? lastAccessed = null,
string ipRegion = null,
Guid? tenantId = null,
CancellationToken cancellationToken = default);
/// <summary>

1
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionManager.cs

@ -68,6 +68,7 @@ public class IdentitySessionManager : DomainService, IIdentitySessionManager
clientIpAddress,
Clock.Now,
Clock.Now,
deviceInfo.IpRegion,
tenantId,
cancellationToken);

6
aspnet-core/modules/identity/LINGYUN.Abp.Identity.Domain/LINGYUN/Abp/Identity/Session/IdentitySessionStore.cs

@ -4,6 +4,7 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Identity;
@ -35,6 +36,7 @@ public class IdentitySessionStore : IIdentitySessionStore, ITransientDependency
string ipAddresses,
DateTime signedIn,
DateTime? lastAccessed = null,
string ipRegion = null,
Guid? tenantId = null,
CancellationToken cancellationToken = default)
{
@ -53,6 +55,10 @@ public class IdentitySessionStore : IIdentitySessionStore, ITransientDependency
signedIn,
lastAccessed
);
if (!ipRegion.IsNullOrWhiteSpace())
{
identitySession.SetProperty("Location", ipRegion);
}
identitySession = await IdentitySessionRepository.InsertAsync(identitySession, cancellationToken: cancellationToken);

Loading…
Cancel
Save