First thanks for such a great sample, you have no idea how long I have spent banging my head against this.
After getting this sample working I decided I want to try to integrate it into the standard ASP Core RC2 sample that comes with the latest Visual Studio.
Now im trying to get it to work with the SQL DB that comes with the sample template. I have modified the TokenController Post function to look like this:
[HttpPost]
public async Task<dynamic> Post(string email, string password)
{
var result = await _signInManager.PasswordSignInAsync(email, password, false, false);
if (result.Succeeded)
{
DateTime? expires = DateTime.UtcNow.AddMinutes(2);
var token = GetToken(email, expires);
return new { authenticated = true, entityId = 1, token = token, tokenExpires = expires };
}
return new { authenticated = false };
}
And that works well. Now I notice that in GetToken() you mention:
// Here, you should create or look up an identity for the user which is being authenticated.
// For now, just creating a simple generic identity.
var identity = new ClaimsIdentity(new GenericIdentity(user, "TokenAuth"), new[] { new Claim("EntityID", "1", ClaimValueTypes.Integer) });
Could you please explain a little about ClaimsIdentity, and Claims and how I should intergrate that with the ASP UserManager / SignInManager?