8
因此,從What is ASP.NET Identity's IUserSecurityStampStore<TUser> interface?我們瞭解到,ASP.NET身份擁有一個安全戳功能,用於使用戶登錄cookie無效,並強制他們重新登錄。ASP.NET身份 - 強制使用安全戳重新登錄
在我的MVC應用程序中,管理員可以歸檔用戶。當成拱形時,他們應該立即被註銷並被迫再次登錄(這會在歸檔後拒絕它們)。
我該怎麼做?我明白安全印章是關鍵。默認的設置是這樣的:
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<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
通過試驗,如果我設置validateInterval喜歡的東西1分鐘,然後在數據庫manaully破解一個用戶的安全標記,然後他們被迫重新登錄,但只在那段時間過去之後。
有沒有辦法讓這個瞬間,或者是它只是一個時間間隔設置爲較低的時間段和等待(或實現我自己的OnValidateIdentity
是在每次請求檢查)
感謝