Skip to content

Commit

Permalink
Added clientIpAddress parameter to query the security logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
maliming committed Dec 26, 2024
1 parent e03ed0f commit 3203430
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Task<List<IdentitySecurityLog>> GetListAsync(
string userName = null,
string clientId = null,
string correlationId = null,
string clientIpAddress = null,
bool includeDetails = false,
CancellationToken cancellationToken = default);

Expand All @@ -34,6 +35,7 @@ Task<long> GetCountAsync(
string userName = null,
string clientId = null,
string correlationId = null,
string clientIpAddress = null,
CancellationToken cancellationToken = default);

Task<IdentitySecurityLog> GetByUserIdAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public virtual async Task<List<IdentitySecurityLog>> GetListAsync(
string userName = null,
string clientId = null,
string correlationId = null,
string clientIpAddress = null,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
Expand All @@ -46,6 +47,7 @@ public virtual async Task<List<IdentitySecurityLog>> GetListAsync(
userName,
clientId,
correlationId,
clientIpAddress,
cancellationToken
);

Expand All @@ -64,6 +66,7 @@ public virtual async Task<long> GetCountAsync(
string userName = null,
string clientId = null,
string correlationId = null,
string clientIpAddress = null,
CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
Expand All @@ -78,6 +81,7 @@ public virtual async Task<long> GetCountAsync(
userName,
clientId,
correlationId,
clientIpAddress,
cancellationToken
);

Expand All @@ -101,6 +105,7 @@ protected virtual async Task<IQueryable<IdentitySecurityLog>> GetListQueryAsync(
string userName = null,
string clientId = null,
string correlationId = null,
string clientIpAddress = null,
CancellationToken cancellationToken = default)
{
return (await GetDbSetAsync()).AsNoTracking()
Expand All @@ -112,6 +117,7 @@ protected virtual async Task<IQueryable<IdentitySecurityLog>> GetListQueryAsync(
.WhereIf(userId.HasValue, securityLog => securityLog.UserId == userId)
.WhereIf(!userName.IsNullOrWhiteSpace(), securityLog => securityLog.UserName == userName)
.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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public virtual async Task<List<IdentitySecurityLog>> GetListAsync(
string userName = null,
string clientId = null,
string correlationId = null,
string clientIpAddress = null,
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
Expand All @@ -45,6 +46,7 @@ public virtual async Task<List<IdentitySecurityLog>> GetListAsync(
userName,
clientId,
correlationId,
clientIpAddress,
cancellationToken
);

Expand All @@ -64,6 +66,7 @@ public virtual async Task<long> GetCountAsync(
string userName = null,
string clientId = null,
string correlationId = null,
string clientIpAddress = null,
CancellationToken cancellationToken = default)
{
var query = await GetListQueryAsync(
Expand All @@ -76,6 +79,7 @@ public virtual async Task<long> GetCountAsync(
userName,
clientId,
correlationId,
clientIpAddress,
cancellationToken
);

Expand All @@ -101,19 +105,19 @@ protected virtual async Task<IQueryable<IdentitySecurityLog>> GetListQueryAsync(
string userName = null,
string clientId = null,
string correlationId = null,
string clientIpAddress = null,
CancellationToken cancellationToken = default)
{
return (await GetMongoQueryableAsync(cancellationToken))
.WhereIf(startTime.HasValue, securityLog => securityLog.CreationTime >= startTime.Value)
.WhereIf(endTime.HasValue, securityLog => securityLog.CreationTime < endTime.Value.AddDays(1).Date)
.WhereIf(!applicationName.IsNullOrWhiteSpace(),
securityLog => securityLog.ApplicationName == applicationName)
.WhereIf(!applicationName.IsNullOrWhiteSpace(), securityLog => securityLog.ApplicationName == applicationName)
.WhereIf(!identity.IsNullOrWhiteSpace(), securityLog => securityLog.Identity == identity)
.WhereIf(!action.IsNullOrWhiteSpace(), securityLog => securityLog.Action == action)
.WhereIf(userId.HasValue, securityLog => securityLog.UserId == userId)
.WhereIf(!userName.IsNullOrWhiteSpace(), securityLog => securityLog.UserName == userName)
.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);
}
}

0 comments on commit 3203430

Please sign in to comment.