0

I've stumbled on this issue and this might be more of a configuration problem on my end but it's been a week and I wasn't able to solve this.

The scenario is; on my Client API startup.cs I have the

services.AddIdentity<TUser,TRole>().AddEntityFrameworkStores<context>();

Initially I don't have any problem at first, my nightmare started when I decided on adding and using policy(ies) and using UserManager in my ApiController using [Authorize(Policy = "GivenPolicy")] work if I remove the services.AddIdentity..... code.

Of course I can live with that but one of my API controller need is for me to use the UserManager which will not resolve if I don't have the services.AddIdentity().AddEntityFrameworkStores().

I hope someone can help me on resolving this issue. TIA.

krlzlx
  • 5,752
  • 14
  • 47
  • 55
chefdev
  • 21
  • 3
  • 2
    Could you highlight what goes wrong? An error message? What fails exactly? – janpieter_z Oct 17 '17 at 09:07
  • Also please provide which version of ASP.Net Core you are using, as Authentication configuration has changed significantly. – tverboon Oct 17 '17 at 10:18
  • @janpieter_z okay problem is when I use the services.AddIdentity().AddEntityFrameworkStores(); in the Startup.cs the [Authorize] attribute is not working meaning even if i'm authenticated I cant access an API controller, but UserManager is being resolve/injected properly, my problem is I need to be able to use the [Authorize] attribute and the UserManager at the same time. – chefdev Oct 17 '17 at 11:38
  • @tverboon I'm using .Netcore 2.0 – chefdev Oct 17 '17 at 11:39

1 Answers1

0

Finally after so many days if ever someone encountered the same problem/issue that I have you can refer on this link:

.Net Core 2.0 Web API using JWT - Adding Identity breaks the JWT authentication

PS: Not sure how to make this post as a link or something.

Anyway, happy coding guys.

chefdev
  • 21
  • 3