【发布时间】:2015-06-29 06:19:28
【问题描述】:
我正在 asp.net mvc 中创建一个 Web 应用程序,它使用表单身份验证来验证用户身份。 我正在使用 HTTP 代理工具“burp”来捕获经过身份验证的用户身份验证的 cookie。之后,我从应用程序中注销。现在我正在使用捕获的经过身份验证的 cookie 向我的服务器发送请求,并且服务器将请求视为经过身份验证的请求(即使该用户从我的浏览器中注销)。 谁能让我知道我的注销代码哪里出错了?
以下是我的应用程序注销代码
public virtual ActionResult LogOff()
{
FormsAuthentication.SignOut();
Session.Abandon();
// clear authentication cookie
HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
cookie1.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie1);
// clear session cookie
HttpCookie cookie2 = new HttpCookie("ASP.NET_SessionId", "");
cookie2.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie2);
HttpCookie cookie3 = new HttpCookie("__RequestVerificationToken", "");
cookie3.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie3);
HttpCookie cookie4 = new HttpCookie(".ASPXAUTH", "");
cookie4.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie4);
return RedirectToAction(MVC.Account.Login());
}
下面是 burp 工具发送认证请求并给出成功响应的屏幕截图
【问题讨论】:
-
我看到
cookie3和cookie4的cookie2属性又要到期了?? -
您能否显示使用捕获的经过身份验证的 cookie 发送请求的代码,以及您何时执行此操作?
-
您能否在设置 cookie 的位置发布您的代码:FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
-
@GuruprasadRao 我没有通过代码发送经过身份验证的请求。我用来捕获请求的 HTTP 代理工具“Burp”具有称为中继器的功能,我正在使用它来发送请求。我在我的问题中添加了相同的屏幕截图
-
@GaneshTodkar 这是我设置身份验证cookie FormsAuthentication.SetAuthCookie(username, true);
标签: asp.net-mvc-4 session authentication cookies burp