【问题标题】:ASP.Net Identity Change Password account lockout does not workASP.Net 身份更改密码帐户锁定不起作用
【发布时间】:2018-05-21 12:01:03
【问题描述】:

我正在使用 ASP.Net 身份。在 changepasswordasync 函数中,无效的旧密码不会触发帐户锁定,是否有办法让这种情况发生?这是 Pen test 提出的低问题。

问候

迈克

【问题讨论】:

  • 嗨 Mike,您是否在 ApplicationUserManager.cs 文件中将 'UserLockoutEnabledByDefault' 值设置为 true?
  • 需要考虑 MaxFailedAccessAttemptsBeforeLockout
  • 我应该提到用户锁定在登录时效果很好。这是否意味着我已经获得了上述设置?
  • 刚刚检查,是的,UserLockoutEnabledByDefault 设置为 true。 MaxFailedAccessAttemptsBeforeLockout 也被设置为一个数字
  • 如果旧密码不正确user.LockoutEnabled = true; user.LockoutEndDateUtc = DateTime.UtcNow.AddMinutes(60); await userManager.UpdateAsync(user);

标签: asp.net .net asp.net-web-api asp.net-identity penetration-testing


【解决方案1】:

如果用户提供了错误的旧密码,您可以通过调用锁定功能来做到这一点

int userId = User.Identity.GetUserId();
IdentityResult result = await UserManager.ChangePasswordAsync(userId , model.OldPassword, model.NewPassword);
if (result.Succeeded)
{
    userManager.ResetAccessFailedCount(userId);
}
else
{
    //you can add logic if the call didn't succeeded because of incorrect old 
    password and then execute the following line
    userManager.AccessFailed(userId);
}

【讨论】:

    猜你喜欢
    • 2021-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-28
    • 2011-03-01
    • 2021-06-29
    • 2019-11-24
    • 1970-01-01
    相关资源
    最近更新 更多