我正在使用Asp.NET Identity 2.1.0
,并且我存储User
有权访问的Accounts
列表。强制另一个用户使用ASP.NET身份刷新其声明2.1.0
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;
}
比方说,一个管理员撤销User A
的特定帐户存取:ClaimsIdentity
当User
迹象产生。我如何强制User A
重新生成ClaimsIdentity
?请记住,它不在User A
的背景下。我不希望等到cookie过期(并且自动生成新的ClaimsIdentity
。
是否有可能?是否有办法告诉服务器将User A
的Cookie视为无效并强制它再生吗?
的原因,我想这种行为是创建一个自定义AuthorizeAttribute
,我可以把我的控制器,检查Claims
看是否有User
访问或没有,以避免额外的往返到数据库
你必须登出它们,对吗?也许这将有所帮助:http://stackoverflow.com/questions/10369225/forcefully-log-out-a-specific-user-among-all-online-users –
@BrendanGreen我真的不想登出去,只是迫使他们重新提出索赔。我可以使用UpdateSecurityStamp强制他们再次登录,但这将是何时令牌过期。 – Joel
您可以将它们注销并使用更新的声明重新登录。 – warheat1990