User-217557848 posted
Hello,
I am specifying to UseCookieAuthentication with the following code:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<SimulatorUserManager, User, Guid>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
// TODO: look up the IUser from the ClaimsIdentity
getUserIdCallback: claimsIdentity => Guid.Empty
)
}
});
Wait for it...
I specify my UserManager, User, and the TKey; in this case, Guid.
In this particular version, figuring this was the best fit for my scenario, "userId" is the User.Id in the domain model.
However, I am pretty sure this one has overlooked that detail in the getUserIdCallback, in that I only have a claimsIdentity. Which I could return claimsIdentity.Name, if I thought that was my Id, which it is not.
The defaults are baked in using the System.String as the key. Could that be one reason why?
I want to use the Guid instead of String, but this detail seems to have been overlooked.
Suggestions?
Thank you...
Regards,
Michael Powell