【问题标题】:How will Identity know to use my custom implementations of its core interfaces?Identity 如何知道使用我的核心接口的自定义实现?
【发布时间】:2016-03-03 00:03:02
【问题描述】:

我发现了两篇相当全面的文章,详细介绍了如何实现像 IUserStore<,> 这样的身份服务,并且几乎完成了它们,例如我有一个:

public class QsaasUserStore<TLogin> : IUserStore<QsaasUser<TLogin>, int> where TLogin : QsaasUserLogin<int>

现在困扰我的是,如何告诉 Identity 在需要用户存储时使用 QsaasUserStore&lt;TLogin&gt;?我是否需要实现方法覆盖,还是可以在 Identity 需要 IUserStore 时使用 Unity 提供我的用户存储?

【问题讨论】:

    标签: security authentication asp.net-web-api asp.net-identity


    【解决方案1】:

    查看UserManagerRoleManagerconstructorsUserManager 在构造函数中依赖于 IUserStore。因此,无论您以何种方式创建UserManager,都应在构造函数中提供IUserStore 的实现。

    RoleManager 也是如此 - 在构造函数中提供 IRoleStore 的实现,您就完成了。

    【讨论】:

      猜你喜欢
      • 2020-11-18
      • 2016-02-03
      • 1970-01-01
      • 1970-01-01
      • 2020-05-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-14
      • 1970-01-01
      相关资源
      最近更新 更多