core
core copied to clipboard
.net core 2.0 Authentication
I have upgrade code 1.1 to 2.0.
We have used app.UseJwtBearerAuthentication and app.UseCookieAuthentication both Authentication.
How i can set both authentication in 2.0. It's looks like only one authentication working at a time.
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.Cookie.Name = JWtToken.CookieName;
options.TicketDataFormat = new CustomJwtDataFormat(
SecurityAlgorithms.HmacSha256,
TokenValidationParameters,
authenticationService);
});
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.SaveToken = true;
options.TokenValidationParameters = TokenValidationParameters;
options.RequireHttpsMetadata = false;
options.Events = new JwtBearerEvents
{
OnTokenValidated = async (context) =>
{
// Add the access_token as a claim, as we may actually need it
var accessToken = context.SecurityToken as JwtSecurityToken;
if (accessToken != null)
{
}
}
};
});
This issue was moved to aspnet/Security#1418