Browse Source

Disable Security Log feature.

pull/4675/head
maliming 6 years ago
parent
commit
40dc60cb6c
  1. 1
      framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/SecurityLog/AspNetCoreSecurityLogManager.cs
  2. 5
      framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/DefaultSecurityLogManager.cs
  3. 10
      framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/SecurityLogInfo.cs
  4. 12
      framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/SimpleSecurityLogStore.cs
  5. 5
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentitySecurityLogStore.cs

1
framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/SecurityLog/AspNetCoreSecurityLogManager.cs

@ -23,7 +23,6 @@ namespace Volo.Abp.AspNetCore.SecurityLog
protected ICurrentClient CurrentClient { get; }
protected IHttpContextAccessor HttpContextAccessor { get; }
protected ICorrelationIdProvider CorrelationIdProvider { get; }
protected IWebClientInfoProvider WebClientInfoProvider { get; }
public AspNetCoreSecurityLogManager(

5
framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/DefaultSecurityLogManager.cs

@ -21,6 +21,11 @@ namespace Volo.Abp.SecurityLog
public async Task SaveAsync(Action<SecurityLogInfo> saveAction = null)
{
if (!SecurityLogOptions.IsEnabled)
{
return;
}
var securityLogInfo = await CreateAsync();
saveAction?.Invoke(securityLogInfo);
await SecurityLogStore.SaveAsync(securityLogInfo);

10
framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/SecurityLogInfo.cs

@ -6,20 +6,10 @@ namespace Volo.Abp.SecurityLog
[Serializable]
public class SecurityLogInfo
{
/// <summary>
/// The name of the application or service writing user security logs.
/// Default: null.
/// </summary>
public string ApplicationName { get; set; }
/// <summary>
/// Web, JWT, Identity, Identity_Server
/// </summary>
public string Identity { get; set; }
/// <summary>
/// login_successful, login_failed, logout, change_pwd, refresh_token...
/// </summary>
public string Action { get; set; }
public Dictionary<string, object> ExtraProperties { get; }

12
framework/src/Volo.Abp.Security/Volo/Abp/SecurityLog/SimpleSecurityLogStore.cs

@ -1,5 +1,6 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.SecurityLog
@ -7,16 +8,23 @@ namespace Volo.Abp.SecurityLog
public class SimpleSecurityLogStore : ISecurityLogStore, ITransientDependency
{
public ILogger<SimpleSecurityLogStore> Logger { get; set; }
protected AbpSecurityLogOptions SecurityLogOptions { get; }
public SimpleSecurityLogStore(ILogger<SimpleSecurityLogStore> logger)
public SimpleSecurityLogStore(ILogger<SimpleSecurityLogStore> logger, IOptions<AbpSecurityLogOptions> securityLogOptions)
{
Logger = logger;
SecurityLogOptions = securityLogOptions.Value;
}
public Task SaveAsync(SecurityLogInfo securityLogInfo)
{
if (!SecurityLogOptions.IsEnabled)
{
return Task.CompletedTask;
}
Logger.LogInformation(securityLogInfo.ToString());
return Task.FromResult(0);
return Task.CompletedTask;
}
}
}

5
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentitySecurityLogStore.cs

@ -34,6 +34,11 @@ namespace Volo.Abp.Identity
public async Task SaveAsync(SecurityLogInfo securityLogInfo)
{
if (!SecurityLogOptions.IsEnabled)
{
return;
}
using (var uow = UnitOfWorkManager.Begin(requiresNew: true))
{
await IdentitySecurityLogRepository.InsertAsync(new IdentitySecurityLog(GuidGenerator, securityLogInfo));

Loading…
Cancel
Save