Disable Security Log feature.

pull/4675/head
maliming 5 years ago
parent 37508abfa2
commit 40dc60cb6c

@ -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(

@ -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);

@ -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; }

@ -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;
}
}
}

@ -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