Raise events for failed login attempts for unknown users
This commit is contained in:
@@ -14,6 +14,11 @@ namespace Umbraco.Core.Auditing
|
||||
public int PerformingUser { get; set; }
|
||||
public string Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This property is always empty except in the LoginFailed event for an unknown user trying to login
|
||||
/// </summary>
|
||||
public string Username { get; set; }
|
||||
|
||||
public IdentityAuditEventArgs(AuditEvent action, string ipAddress = "", int performingUser = -1)
|
||||
{
|
||||
DateTimeUtc = DateTime.UtcNow;
|
||||
|
||||
@@ -386,6 +386,15 @@ namespace Umbraco.Core.Security
|
||||
});
|
||||
}
|
||||
|
||||
public void RaiseInvalidLoginAttemptEvent(string username)
|
||||
{
|
||||
OnLoginFailed(new IdentityAuditEventArgs(AuditEvent.LoginFailed)
|
||||
{
|
||||
Username = username,
|
||||
Comment = string.Format("Attempted login for username '{0}' failed", username)
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears a lock so that the membership user can be validated.
|
||||
/// </summary>
|
||||
|
||||
@@ -185,10 +185,12 @@ namespace Umbraco.Web.Editors
|
||||
case SignInStatus.LockedOut:
|
||||
case SignInStatus.Failure:
|
||||
default:
|
||||
//return BadRequest (400), we don't want to return a 401 because that get's intercepted
|
||||
//return BadRequest (400), we don't want to return a 401 because that get's intercepted
|
||||
// by our angular helper because it thinks that we need to re-perform the request once we are
|
||||
// authorized and we don't want to return a 403 because angular will show a warning msg indicating
|
||||
// that the user doesn't have access to perform this function, we just want to return a normal invalid msg.
|
||||
// authorized and we don't want to return a 403 because angular will show a warning msg indicating
|
||||
// that the user doesn't have access to perform this function, we just want to return a normal invalid msg.
|
||||
if (UserManager != null)
|
||||
UserManager.RaiseInvalidLoginAttemptEvent(loginModel.Username);
|
||||
throw new HttpResponseException(HttpStatusCode.BadRequest);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user