0

I'm trying to migrate my asp.net core 1.1 project to asp.net core 2.0. I've used the guidelines from her to implement jwt authentication.

Now that I've upgraded to 2.0, I've used the guidelines in here and here to migrate, but HttpContext.User.Identity.IsAuthenticated is false.

The client correctly sends the bearer token. Any links or pointers are appreciated.

Alireza
  • 5,421
  • 5
  • 34
  • 67
  • 1
    Not sure, but maybe this will help https://stackoverflow.com/questions/45261732/user-identity-isauthenticated-always-false-in-net-core-custom-authentication – user2771704 Aug 16 '17 at 12:23
  • Running into the same problem. And it no longer returns `Unauthorized` but tries to redirect to a non-existent login page. – Knelis Aug 18 '17 at 09:12
  • @user2771704 My problem is not that. We user the parametered constructor – Alireza Aug 19 '17 at 06:11
  • @Knelis It's another symptom of the same problem. The user is not correctly authenticated – Alireza Aug 19 '17 at 06:12
  • 1
    If you're using `.AddIdentity`, that actually sets some default parameters for authentication. What I did to get it working for JWT bearer only is override those settings like this: `services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultForbidScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultSignInScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer( ... );` – Knelis Aug 21 '17 at 07:43

0 Answers0