Difference beetween authentication with cookies and JWT
Hi, I would like to know if you can give me the difference between authentication with cookies and JWT.
Also, I would like to know if I can make an authorisation of my application Independently of the authentication method use : cookies or JWT.
Program.cs in server project : cookie method
builder.Services.ConfigureApplicationCookie(options =>
{
options.Cookie.HttpOnly = false;
options.Events.OnRedirectToLogin = context =>
{
context.Response.StatusCode = 401;
return Task.CompletedTask;
};
});
Program.cs in server project : cookie method
//builder.Services.AddAuthentication(opt =>
//{
// opt.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
// opt.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
//}).AddJwtBearer(options =>
//{
// options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
// {
// ValidateIssuer = true,
// ValidateAudience = true,
// ValidateLifetime = true,
// ValidateIssuerSigningKey = true,
// ValidIssuer = jwtSettings["validIssuer"],
// ValidAudience = jwtSettings["validAudience"],
// IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings))
// };
//});
Thanks in advance to your reply
6 answers
Sort by: Most helpful
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more