So from ASP.NET Identity 的 IUserSecurityStampStore 接口是什么?我们了解到 ASP.NET Identity 具有安全标记功能,用于使用户登录 cookie 无效,并强制他们重新登录。
在我的 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 分钟之类的值,然后手动破解数据库中的用户安全标记,那么他们将被迫重新登录,但只有在该时间段过后。
有没有办法让这个瞬间发生,或者只是将间隔设置为一个较短的时间段并等待(或实现我自己的)OnValidateIdentity
检查每个请求)
Thanks
您正确地陈述了您的选项,要么是低间隔/等待,要么是挂钩您自己的自定义OnValidateIdentity
.
这是一个类似的问题:立即传播角色变化
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)