mirror of
https://github.com/bitwarden/server.git
synced 2025-03-10 13:09:12 +01:00
login failed log message
This commit is contained in:
parent
8f3df46075
commit
d022517762
src
@ -17,6 +17,7 @@ using Bit.Core.Models.Data;
|
|||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Bit.Core.IdentityServer
|
namespace Bit.Core.IdentityServer
|
||||||
{
|
{
|
||||||
@ -32,6 +33,7 @@ namespace Bit.Core.IdentityServer
|
|||||||
private readonly IOrganizationUserRepository _organizationUserRepository;
|
private readonly IOrganizationUserRepository _organizationUserRepository;
|
||||||
private readonly IApplicationCacheService _applicationCacheService;
|
private readonly IApplicationCacheService _applicationCacheService;
|
||||||
private readonly IMailService _mailService;
|
private readonly IMailService _mailService;
|
||||||
|
private readonly ILogger<ResourceOwnerPasswordValidator> _logger;
|
||||||
private readonly CurrentContext _currentContext;
|
private readonly CurrentContext _currentContext;
|
||||||
private readonly GlobalSettings _globalSettings;
|
private readonly GlobalSettings _globalSettings;
|
||||||
|
|
||||||
@ -46,6 +48,7 @@ namespace Bit.Core.IdentityServer
|
|||||||
IOrganizationUserRepository organizationUserRepository,
|
IOrganizationUserRepository organizationUserRepository,
|
||||||
IApplicationCacheService applicationCacheService,
|
IApplicationCacheService applicationCacheService,
|
||||||
IMailService mailService,
|
IMailService mailService,
|
||||||
|
ILogger<ResourceOwnerPasswordValidator> logger,
|
||||||
CurrentContext currentContext,
|
CurrentContext currentContext,
|
||||||
GlobalSettings globalSettings)
|
GlobalSettings globalSettings)
|
||||||
{
|
{
|
||||||
@ -59,6 +62,7 @@ namespace Bit.Core.IdentityServer
|
|||||||
_organizationUserRepository = organizationUserRepository;
|
_organizationUserRepository = organizationUserRepository;
|
||||||
_applicationCacheService = applicationCacheService;
|
_applicationCacheService = applicationCacheService;
|
||||||
_mailService = mailService;
|
_mailService = mailService;
|
||||||
|
_logger = logger;
|
||||||
_currentContext = currentContext;
|
_currentContext = currentContext;
|
||||||
_globalSettings = globalSettings;
|
_globalSettings = globalSettings;
|
||||||
}
|
}
|
||||||
@ -216,6 +220,8 @@ namespace Bit.Core.IdentityServer
|
|||||||
twoFactorRequest ? EventType.User_FailedLogIn2fa : EventType.User_FailedLogIn);
|
twoFactorRequest ? EventType.User_FailedLogIn2fa : EventType.User_FailedLogIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logger.LogWarning(Constants.BypassFiltersEventId, "Failed login attempt.{0}",
|
||||||
|
twoFactorRequest ? " 2FA invalid." : string.Empty);
|
||||||
await Task.Delay(2000); // Delay for brute force.
|
await Task.Delay(2000); // Delay for brute force.
|
||||||
context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant,
|
context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant,
|
||||||
customResponse: new Dictionary<string, object>
|
customResponse: new Dictionary<string, object>
|
||||||
|
@ -17,7 +17,8 @@ namespace Bit.Identity
|
|||||||
logging.AddSerilog(hostingContext, e =>
|
logging.AddSerilog(hostingContext, e =>
|
||||||
{
|
{
|
||||||
var context = e.Properties["SourceContext"].ToString();
|
var context = e.Properties["SourceContext"].ToString();
|
||||||
if(context.Contains(typeof(IpRateLimitMiddleware).FullName) && e.Level == LogEventLevel.Information)
|
if(context.Contains(typeof(IpRateLimitMiddleware).FullName) &&
|
||||||
|
e.Level == LogEventLevel.Information)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user