我创建了一个ASP.NET MVC5应用程序,允许用户访问他们的财务数据,包括他们从我们公司获得的发票,服务和产品 .

应用程序从一组WCF服务获取所有数据,包括可以访问系统的所有注册用户的列表 . 我正在使用ASP.NET Identity对象并声称授权用户进入应用程序,一切正常我只需要使用凭据(电子邮件和密码)来调用WCF服务,该服务返回包含有关User或a的详细信息的对象如果没有匹配则为NULL值 .

但是,在5次登录尝试失败后(帐户将被锁定20分钟,然后再允许用户再次尝试),实现帐户锁定的新要求已经包含在ASP.NET身份2.0中 . 我已经“谷歌搜索”了几天,但没有找到如何实现此要求的示例(甚至类似的方法),而不将用户存储在Entity Framework和本地数据库中 .

有没有办法使用WCF服务作为我的ASP.NET MVC5应用程序的数据源添加帐户锁定功能(使用20分钟锁定)?有任何想法吗?

这实际上是我的第一个ASP.NET MVC5应用程序,所以对它提供的所有功能并不是很了解,任何帮助都将不胜感激 .

这是登录(POST)的样子:

//Authentication handler
    IAuthenticationManager Authentication
    {
        get { return HttpContext.GetOwinContext().Authentication; }
    }

    [HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public ActionResult Login(LoginViewModel model, string returnUrl)
    {
        if (ModelState.IsValid)
        {
            try
            {  
                //Validate user from service
                CWP_AccountService.User userObject = AccountClient.GetUserByCredentials(model.Email, model.Password);
                if (userObject != null)
                {
                   //Create Claims
                    var identity = new ClaimsIdentity(
                                new[] { new Claim(ClaimTypes.Name, userObject.Email) },
                                DefaultAuthenticationTypes.ApplicationCookie,
                                ClaimTypes.Name, ClaimTypes.Role);

                    identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, userObject.Email));
                    identity.AddClaim(new Claim(ClaimTypes.Sid, userObject.UserID.ToString()));

                    int cookieDurationPersistence = 20160;
                    int cookieDuration = 2;

                    Authentication.SignIn(new AuthenticationProperties { IsPersistent = model.RememberMe, ExpiresUtc = (model.RememberMe) ? DateTime.Now.AddMinutes(cookieDurationPersistence) : DateTime.Now.AddMinutes(cookieDuration) }, identity);

                     //Check if there is a local return URL
                     if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                     {
                         return RedirectToLocal(returnUrl);
                     }

                     return RedirectToAction("Index", "Home");
                }
                else
                {
                     ModelState.AddModelError("system-error", "The Email/Password provided is not valid.");
                } 

            }
            catch(Exception ex)
            {
                ModelState.AddModelError("system-error", "Error");
                logger.Warn(ex.ToString());
            }                
        }


        return View(model);
    }

Startup.Auth.cs

public partial class Startup
{
        public void ConfigureAuth(IAppBuilder app)
        {
            // Enable the application to use a cookie to store information for the signed in user
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, 
                LoginPath = new PathString("/Account/Login")
            });         

        }
}