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.

4
  • 2
    Could you highlight what goes wrong? An error message? What fails exactly? Commented Oct 17, 2017 at 9:07
  • Also please provide which version of ASP.Net Core you are using, as Authentication configuration has changed significantly. Commented Oct 17, 2017 at 10:18
  • @janpieter_z okay problem is when I use the services.AddIdentity<TUser,TRole>().AddEntityFrameworkStores<context>(); in the Startup.cs the [Authorize] attribute is not working meaning even if i'm authenticated I cant access an API controller, but UserManager<User> 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. Commented Oct 17, 2017 at 11:38
  • @tverboon I'm using .Netcore 2.0 Commented Oct 17, 2017 at 11:39

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.