I am working on an authentication system that uses an ASP.NET identifier with the Entity Framework, and I want to have a few statements that are computed values, not hard-coded into the claims table.
When a user logs in, how can I add dynamic requirements to this login session without adding them to the claims table?
For example, I might want to save each user DOB, but I want to add IsBirthday as a claim if the login date matches the user DOB. I do not want to store the IsBirthday application for each user, as it changes daily for everyone.
In my code, I use this to login:
var signInResult = await SignInManager.PasswordSignInAsync(username, password, false, false);
After this is called, I can reference the ClaimsPrincipal, but the Claims property is IEnumerable, not List, so I cannot add it.
EDIT: I should also mention that I use the Microsoft.AspNet.Identity.Owin libraries.
source share