Browse Source

Added `clientIpAddress` parameter to query the `security logs`.

pull/21735/head
maliming 2 years ago
parent
commit
32034300db
No known key found for this signature in database GPG Key ID: A646B9CB645ECEA4
  1. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentitySecurityLogRepository.cs
  2. 8
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentitySecurityLogRepository.cs
  3. 12
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentitySecurityLogRepository.cs

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IIdentitySecurityLogRepository.cs

@ -21,6 +21,7 @@ public interface IIdentitySecurityLogRepository : IBasicRepository<IdentitySecur
string userName = null, string userName = null,
string clientId = null, string clientId = null,
string correlationId = null, string correlationId = null,
string clientIpAddress = null,
bool includeDetails = false, bool includeDetails = false,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
@ -34,6 +35,7 @@ public interface IIdentitySecurityLogRepository : IBasicRepository<IdentitySecur
string userName = null, string userName = null,
string clientId = null, string clientId = null,
string correlationId = null, string correlationId = null,
string clientIpAddress = null,
CancellationToken cancellationToken = default); CancellationToken cancellationToken = default);
Task<IdentitySecurityLog> GetByUserIdAsync( Task<IdentitySecurityLog> GetByUserIdAsync(

8
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentitySecurityLogRepository.cs

@ -31,6 +31,7 @@ public class EfCoreIdentitySecurityLogRepository : EfCoreRepository<IIdentityDbC
string userName = null, string userName = null,
string clientId = null, string clientId = null,
string correlationId = null, string correlationId = null,
string clientIpAddress = null,
bool includeDetails = false, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
@ -46,6 +47,7 @@ public class EfCoreIdentitySecurityLogRepository : EfCoreRepository<IIdentityDbC
userName, userName,
clientId, clientId,
correlationId, correlationId,
clientIpAddress,
cancellationToken cancellationToken
); );
@ -64,6 +66,7 @@ public class EfCoreIdentitySecurityLogRepository : EfCoreRepository<IIdentityDbC
string userName = null, string userName = null,
string clientId = null, string clientId = null,
string correlationId = null, string correlationId = null,
string clientIpAddress = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
cancellationToken = GetCancellationToken(cancellationToken); cancellationToken = GetCancellationToken(cancellationToken);
@ -78,6 +81,7 @@ public class EfCoreIdentitySecurityLogRepository : EfCoreRepository<IIdentityDbC
userName, userName,
clientId, clientId,
correlationId, correlationId,
clientIpAddress,
cancellationToken cancellationToken
); );
@ -101,6 +105,7 @@ public class EfCoreIdentitySecurityLogRepository : EfCoreRepository<IIdentityDbC
string userName = null, string userName = null,
string clientId = null, string clientId = null,
string correlationId = null, string correlationId = null,
string clientIpAddress = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return (await GetDbSetAsync()).AsNoTracking() return (await GetDbSetAsync()).AsNoTracking()
@ -112,6 +117,7 @@ public class EfCoreIdentitySecurityLogRepository : EfCoreRepository<IIdentityDbC
.WhereIf(userId.HasValue, securityLog => securityLog.UserId == userId) .WhereIf(userId.HasValue, securityLog => securityLog.UserId == userId)
.WhereIf(!userName.IsNullOrWhiteSpace(), securityLog => securityLog.UserName == userName) .WhereIf(!userName.IsNullOrWhiteSpace(), securityLog => securityLog.UserName == userName)
.WhereIf(!clientId.IsNullOrWhiteSpace(), securityLog => securityLog.ClientId == clientId) .WhereIf(!clientId.IsNullOrWhiteSpace(), securityLog => securityLog.ClientId == clientId)
.WhereIf(!correlationId.IsNullOrWhiteSpace(), securityLog => securityLog.CorrelationId == correlationId); .WhereIf(!correlationId.IsNullOrWhiteSpace(), securityLog => securityLog.CorrelationId == correlationId)
.WhereIf(!clientIpAddress.IsNullOrWhiteSpace(), securityLog => securityLog.ClientIpAddress == clientIpAddress);
} }
} }

12
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentitySecurityLogRepository.cs

@ -32,6 +32,7 @@ public class MongoIdentitySecurityLogRepository :
string userName = null, string userName = null,
string clientId = null, string clientId = null,
string correlationId = null, string correlationId = null,
string clientIpAddress = null,
bool includeDetails = false, bool includeDetails = false,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
@ -45,6 +46,7 @@ public class MongoIdentitySecurityLogRepository :
userName, userName,
clientId, clientId,
correlationId, correlationId,
clientIpAddress,
cancellationToken cancellationToken
); );
@ -64,6 +66,7 @@ public class MongoIdentitySecurityLogRepository :
string userName = null, string userName = null,
string clientId = null, string clientId = null,
string correlationId = null, string correlationId = null,
string clientIpAddress = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
var query = await GetListQueryAsync( var query = await GetListQueryAsync(
@ -76,6 +79,7 @@ public class MongoIdentitySecurityLogRepository :
userName, userName,
clientId, clientId,
correlationId, correlationId,
clientIpAddress,
cancellationToken cancellationToken
); );
@ -101,19 +105,19 @@ public class MongoIdentitySecurityLogRepository :
string userName = null, string userName = null,
string clientId = null, string clientId = null,
string correlationId = null, string correlationId = null,
string clientIpAddress = null,
CancellationToken cancellationToken = default) CancellationToken cancellationToken = default)
{ {
return (await GetMongoQueryableAsync(cancellationToken)) return (await GetMongoQueryableAsync(cancellationToken))
.WhereIf(startTime.HasValue, securityLog => securityLog.CreationTime >= startTime.Value) .WhereIf(startTime.HasValue, securityLog => securityLog.CreationTime >= startTime.Value)
.WhereIf(endTime.HasValue, securityLog => securityLog.CreationTime < endTime.Value.AddDays(1).Date) .WhereIf(endTime.HasValue, securityLog => securityLog.CreationTime < endTime.Value.AddDays(1).Date)
.WhereIf(!applicationName.IsNullOrWhiteSpace(), .WhereIf(!applicationName.IsNullOrWhiteSpace(), securityLog => securityLog.ApplicationName == applicationName)
securityLog => securityLog.ApplicationName == applicationName)
.WhereIf(!identity.IsNullOrWhiteSpace(), securityLog => securityLog.Identity == identity) .WhereIf(!identity.IsNullOrWhiteSpace(), securityLog => securityLog.Identity == identity)
.WhereIf(!action.IsNullOrWhiteSpace(), securityLog => securityLog.Action == action) .WhereIf(!action.IsNullOrWhiteSpace(), securityLog => securityLog.Action == action)
.WhereIf(userId.HasValue, securityLog => securityLog.UserId == userId) .WhereIf(userId.HasValue, securityLog => securityLog.UserId == userId)
.WhereIf(!userName.IsNullOrWhiteSpace(), securityLog => securityLog.UserName == userName) .WhereIf(!userName.IsNullOrWhiteSpace(), securityLog => securityLog.UserName == userName)
.WhereIf(!clientId.IsNullOrWhiteSpace(), securityLog => securityLog.ClientId == clientId) .WhereIf(!clientId.IsNullOrWhiteSpace(), securityLog => securityLog.ClientId == clientId)
.WhereIf(!correlationId.IsNullOrWhiteSpace(), .WhereIf(!correlationId.IsNullOrWhiteSpace(), securityLog => securityLog.CorrelationId == correlationId)
securityLog => securityLog.CorrelationId == correlationId); .WhereIf(!clientIpAddress.IsNullOrWhiteSpace(), securityLog => securityLog.ClientIpAddress == clientIpAddress);
} }
} }

Loading…
Cancel
Save