Cookie path and expiry is not working or set after authentication cookie in asp.net core
Date : March 29 2020, 07:55 AM
I hope this helps . At start remove doubled comma in Response.Cookies.Append and will work (but you need to be on /user path to see that cookie)
|
How does ASP.NET Core know that cookie is valid in cookie authentication?
Date : March 29 2020, 07:55 AM
|
Asp.net Core Persistent Authentication - Custom Cookie Authentication
Date : March 29 2020, 07:55 AM
I hope this helps you . The persistence granted by IsPersistent is, according to the docs, only meant to imply that the authentication will persist through browsing sessions (that is, it is kept even when the browser is closed). You need a combination of Persistence and to set an expiration time for the cookie. The expiration of the cookie can be set via the CookieAuthenticationOptions (MSDN), using the ExpireTimeSpan option. Without persistence, expiration of the authentication can be set using the ExpiresUtc option in AuthenticationOptions,
|
setting asp.net CORE 2 authentication cookie while using bearer token authentication
Date : March 29 2020, 07:55 AM
this will help You can have both Cookies and JWT authentication at the same time in one project. first add both cookie and JWT authentication in ConfigureServices method: services.AddAuthentication()
.AddCookie(options => options.SlidingExpiration = true)
.AddJwtBearer(options =>
{
// JWT setup
});
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
Cookie authentication not working properly with JWT authentication ASP.NET CORE
Date : March 29 2020, 07:55 AM
seems to work fine After more digging, I stumbled on this thread, which answered my question. I had misunderstood how authentication works in an asp.net core app that uses identity. When you use Identity to authenticate and login a user, the default authentication scheme used is called "Identity.Applicaiton" and not "Cookies". var result = await _signInManager.PasswordSignInAsync(loginModel.Email, loginModel.Password, true, false);
if (result.Succeeded)
{
return LocalRedirect("/home/index");
}
var claims = new[]
{
new Claim("email", user.Email),
};
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
new ClaimsPrincipal(identity));
|