I have a dotnet core api app with windows app enabled. We have bunch of users which have special permission 'admin' and are stored in database, rest all have default permission 'user'. I want users to have extra claims who all are in database. Also I want to store more information like emailid, employee number(which I have to query from LDAP manually)
What I thought is I will have one api, say api/auth
which will capture the current user and add claims based on database and ldap query and other api end points can use it.
But I am not able to get how to add and persist claims between different api end points.
Is it possible, and or is it a good way? I have second option to hit the database on each api call.
Edit 1:
I have written a middleware which intercepts all api request and searches LDAP/database, creates an ClaimsIndentity
and add it to Users.Identity
. Then it is available through rest of the call.
Edit 2:
When I am @Ondra Starenko's answer, I am not able to reference IClaimsTransformer
or app.UseClaimsTransformation
. Is there something else I need to include.
Platform: .NET core 2.1.3