0

I have an action method which is anonymous.

I have cookie authentication scheme and JWT bearer scheme. Cookie is the default authentication scheme.

Now, in my action method if I specify the JWT authentication scheme then token validated and user is authenticated user.

[Authorize(AuthenticationSchemes = CookieAuthenticationDefaults.AuthenticationScheme + "," + JwtBearerDefaults.AuthenticationScheme)]
public IActionResult Get()

If the method is antonymous then JWT token is not validated and user is antonymous,

[AllowAnonymous]
public IActionResult Get()

Is there way to trigger the JWT and cookie

Imran Qadir Baksh - Baloch
  • 32,612
  • 68
  • 179
  • 322

1 Answers1

0

Thanks to this post which allows me to fix this issue Use multiple JWT Bearer Authentication

 services.AddAuthorization(options =>
            {
                options.DefaultPolicy = new AuthorizationPolicyBuilder()
                .RequireAuthenticatedUser()
                .AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme, IdentityConstants.ApplicationScheme)
                .Build();
            });
Imran Qadir Baksh - Baloch
  • 32,612
  • 68
  • 179
  • 322