ASP.NET標識的IUserSecurityStampStore<TUser>接口是什么?查看ASP.NET標識(ASP.NET中的新成員關系實現),我在實現自己的接口時遇到了這個接口UserStore://Microsoft.AspNet.Identity.Core.dllnamespace Microsoft.AspNet.Identity{
public interface IUserSecurityStampStore<TUser> :
{
// Methods
Task<string> GetSecurityStampAsync(TUser user);
Task SetSecurityStampAsync(TUser user, string stamp);
}}IUserSecurityStampStore在默認情況下實現。EntityFramework.UserStore<TUser>從本質上獲取并設置TUser.SecurityStamp財產。經過進一步的挖掘,似乎SecurityStamp是Guid中的關鍵點新生成的UserManager(例如,更改密碼)。除了這個,我不能破譯更多的代碼,因為我正在檢查這段代碼反射器..幾乎所有的符號和異步信息都被優化了。此外,谷歌對此也沒有多大幫助。問題如下:什么是SecurityStamp在ASP.NET標識中,它用于什么?是否SecurityStamp在創建身份驗證cookie時扮演什么角色?是否需要采取任何安全措施或預防措施?例如,不要將此值向下發送給客戶端?這里有源代碼:https://github.com/aspnet/Identity/https://github.com/aspnet/Security/
3 回答

MM們
TA貢獻1886條經驗 獲得超2個贊
更新為2.0.0。SecurityStamp
OnValidateIdentity
CookieMiddleware
SecurityStamp
refreshInterval
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)) }});
UserManager.UpdateSecurityStampAsync(userId);

隔江千里
TA貢獻1906條經驗 獲得超10個贊
services.Configure<SecurityStampValidatorOptions>(o => o.ValidationInterval = TimeSpan.FromSeconds(10));
- 3 回答
- 0 關注
- 543 瀏覽
添加回答
舉報
0/150
提交
取消