相关疑难解决方法(0)

什么是ASP.NET Identity的IUserSecurityStampStore <TUser>接口?

看看ASP.NET Identity(ASP.NET中的新成员实现),我在实现自己的时遇到了这个界面UserStore:

//Microsoft.AspNet.Identity.Core.dll

namespace Microsoft.AspNet.Identity
{ 
    public interface IUserSecurityStampStore<TUser> :
    {
        // Methods
        Task<string> GetSecurityStampAsync(TUser user);
        Task SetSecurityStampAsync(TUser user, string stamp);
    }
}
Run Code Online (Sandbox Code Playgroud)

IUserSecurityStampStore由默认实现EntityFramework.UserStore<TUser>,实质上获取和设置TUser.SecurityStamp属性.

经过一些挖掘之后,似乎a SecurityStampGuid在关键点新生成的UserManager(例如,更改密码).

因为我在Reflector中检查这段代码,所以我无法真正破译.几乎所有的符号和异步信息都已经过优化.

此外,谷歌也没有太多帮助.

问题是:

  • 什么是SecurityStampASP.NET标识,它用于什么?
  • SecurityStamp创建身份验证cookie时,是否扮演任何角色?
  • 是否有任何需要采取的安全措施或预防措施?例如,不要将此值向下游发送给客户端?

更新(2014年9月16日)

源代码在这里:

asp.net asp.net-mvc asp.net-mvc-5 asp.net-identity

168
推荐指数
3
解决办法
6万
查看次数

如何使用ASP.NET Identity 2.0.1强制将角色更改传播给用户?

我已经阅读了这篇文章,虽然它解释了在一段时间间隔后角色更改最终会如何传播到用户cookie,但我仍然不明白我是如何强制立即更改用户角色的.

当我更改管理员角色时,是否真的必须签署用户?如果是这样 - 怎么样?如果我使用AuthenticationManager.SignOut();然后我签署自己(管理员),而不是用户,我想改变他们的角色.

目前我await UserManager.UpdateSecurityStampAsync(user.Id);用来生成一个新的安全标记,但它不起作用.当我以另一个用户身份登录时在另一个浏览器中刷新页面时,他的声明(包括安全标记)不会更改.

c# asp.net asp.net-mvc-5 asp.net-identity-2

26
推荐指数
1
解决办法
8944
查看次数

如何在ASP.NET Core Identity中注销其他用户

如何在ASP.NET Core Identity中注销另一个用户(不是当前记录的用户).

我知道有一个SignOutAsync()方法SignInManager,但似乎没有覆盖接受用户作为参数.我正在寻找类似的东西:

signInManager.SignOutAsync(user);
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-mvc asp.net-core asp.net-core-identity

11
推荐指数
1
解决办法
8233
查看次数

如何强制更新自定义用户声明?

我在 ApplicationUser 类中添加了一个自定义声明,如下所示:

public class ApplicationUser : IdentityUser
{
    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
    {
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        // Add custom user claims here
        if(Theme != null)
            userIdentity.AddClaim(new Claim("ThemeBundle", Theme.Bundle));

        return userIdentity;
    }

    public int? ThemeId { get; set; }
    [ForeignKey("ThemeId")]
    public virtual Theme Theme { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我像这样扩展了 Identity:

public static class IdentityExtensions
{
    public static string GetThemeBundle(this IIdentity identity)
    {
        var claim = ((ClaimsIdentity) identity).FindFirst("ThemeBundle");
        // Test for null to avoid issues during …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc claims-based-identity asp.net-identity

5
推荐指数
1
解决办法
2682
查看次数