I'm developing a data project with ASP.NET Core and Entity Framework Core. We're starting to use user claims (Identity) to manage authorization for things like managers etc. Previously, we had a separate table for managers, so that each permission could be set on each object and we looked it up as required.
Simple example prior to UserClaims:
Store { StoreId, Name etc... plus ICollection<ManagerPermissions> }
User { StoreId, Name, Email etc}
ManagerPermissions { StoreId, UserId }
Using the separate ManagerPermissions table meant it was easy to list the relevant manager(s) for that store by using a navigation property like ICollection<ManagerPermissions>. If writing a query, I could do _context.Store.Include(s => s.ManagerPermissions) to include a list of managers to display.
Now that we're using user claims, I haven't found an easy way to do this. I've extended IdentityDbContext so the claims data is held within the same database as the other data.
I have seen
UserManager.GetUsersWithClaimAsync({ ClaimType="ismanager", ClaimValue = StoreId})
but this requires an instance of userManager and also a separate roundtrip to the database. The only other way I could think of is by doing a join on UserClaims table, but I'm not sure the most efficient way of doing this.