[.NET Core] Why does Identity always creates cookies even when using JWT as default authentication scheme?
Pardon me if this comes as noobish but I am learning .NET Core and since everyone I know suggested to use JWT for authentication, I decided to go with it. However, I am utterly confused as to why Identity always creates a cookie regardless of the type of authentication I choose. And when checking for current user (authenticated) it goes with the cookie and ignoring the Authorization Bearer header. I have set JWT as default authentication in Startup like this:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.SaveToken = true; options.TokenValidationParameters = new TokenValidationParameters { ClockSkew = TimeSpan.Zero, ValidateIssuer = true, ValidateAudience = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ValidIssuer = Configuration["Jwt:Issuer"], ValidAudience = Configuration["Jwt:Audience"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"])) }; });
What am I doing wrong?
0 comments:
Post a Comment