core icon indicating copy to clipboard operation
core copied to clipboard

.net core 2.0 Authentication

Open chintan3100 opened this issue 9 years ago • 1 comments

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)
                    {
           
                    }
                }
            };
        });

chintan3100 avatar Sep 12 '17 14:09 chintan3100

This issue was moved to aspnet/Security#1418

blowdart avatar Sep 12 '17 15:09 blowdart