I've an ASP.NET Core (based on .NET Framework) using Windows Authentication. Point is, I need to add a role claim on that user and this role is stored in a distant database.
I've read so much thing about OWIN/Cookie/UserManager/UserStore/Identity and so on that I'm lost.
Question : How do I add a role claim for current user logged in (windows) for the whole application in the easiest way?
What I need is to easily use [Authorize(Role= "MyAddedRole")]
or bool res = User.IsInRole("MyAddedRole")
Thanks
Best Answer
Answering myself, so what I did :
Create my own UserClaimStore (I only need this store, not the others):
Then created my own ClaimTransformer :
Endly, in Startup.cs :
And now I can freely use
[Authorize(Roles = "MyRole")]
orUser.IsInRole("MyRole")
or evenUser.HasClaim(/* */)
!