I use the asp.net 2.0 identifier for authentication (Owin middleware) in my application. Session Capture: When I log into the Identity system creates AspNet.ApplicationCookie.then, I copied the AspNet.ApplicationCookie value. Then I left the application. After logging out, I create a cookie manually (AspNet.ApplicationCookie) and update it. Redirects me to the home page.
Priority Escalation: At the same time, I logged in as a user AI copied (AspNet.ApplicationCookie), its cookie, and I logged out. After I logged in as user BI, I edited the User B Cookie and inserted the user's cookie into the cookie and saved it. After updating in the browser, I can access and authenticate UserA.
I clear my entire session and delete all cookies. When I logged out. Another Asp.Net user (Owin) generates a new AspNet.ApplicationCookie each time. But he still accepts old cookies and gives me access. I do not know why? Can someone give me how to invalidate the old AspNet.ApplicationCookie after logging out. This is my code in Startup.Auth.cs
public void ConfigureAuth(IAppBuilder app) {
// This is the exit code
public ActionResult LogOff ( ) { //Delete all cookies while user log out string[] myCookies = Request.Cookies.AllKeys; foreach ( var cookies in myCookies ) { Response.Cookies[ cookies ].Expires = DateTime.Now.AddDays(-1); } Request.GetOwinContext( ).Authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie); // AuthenticationManager.SignOut( ); Session.Clear( ); Session.RemoveAll( ); Session.Abandon( ); return RedirectToAction("LoginPage", "Account"); }
// This is my login controller code
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var user = await UserManager.FindAsync(model.UserName, model.Password); if (user != null) { await SignInAsync(user, model.RememberMe); return RedirectToLocal(returnUrl); } else { ModelState.AddModelError("", "Invalid username or password."); } }
source share