I'm using Asp.NET Identity 2.1.0
and I store a list of Accounts
that a User
has access to, as Claims. The ClaimsIdentity
is generated when the User
signs in:
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add Claims concerning Account
userIdentity.AddClaim(new Claim("AccountList", SerializedListOfAccounts));
return userIdentity;
}
Let's say that an Administrator revokes User A
's access to a specific Account. How can I force User A
to regenerate its ClaimsIdentity
? Remember that it isn't in the context of User A
. And I don't want to wait until the cookie has expired (and a new ClaimsIdentity
is automatically generated.
Is it possible? Isn't there a way to tell the server to regard User A
's cookie as invalid and force it to regenerate it?
The reason I want this behaviour is to create a custom AuthorizeAttribute
that I can put on my controllers that checks the Claims
to see if a User
has access or not, to avoid an extra round trip to the database.