Using ASP.NET Identity 2.1.0,
I am trying to add a custom claim so that it is added to the rounding cookie and not added to the data store.
The claim is intended for a unique session identifier, a unique login, even if for the same UserId (for a better audit of operations performed on each Session / Client IP address).
Trying so far:
Provider = new CookieAuthenticationProvider
{
OnResponseSignIn = (x) =>
{
var st = x.Identity.FindFirstValue("ST");
if (string.IsNullOrEmpty(st))
{
st = Guid.NewGuid().ToString();
}
x.Identity.AddClaim(new Claim("ST", st));
x.OwinContext.Authentication.SignIn(x.Identity);
},
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromSeconds(6),
regenerateIdentity: async (manager, user) =>
{
var x = await user.GenerateUserIdentityAsync(manager);
return x;
}
)
}
});
using the cache (Session / load balanced Shared / etc.) for SessionId, using UserId, since the key will obviously not work (it will return the same SessionId, regardless of ClientIP)
using UserId + ClientIP, because the key will return SessionId ... But ClientIP is noticeably error prone, so it will fail.
cookie, , , cookie - , , , ....
- (, ) ?
, Cookie Identity, , , ? ?
!