本文介绍了在Identity示例项目DataProtectionProvider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

官方身份2示例项目在 UserManager.Create低于code()

The official Identity 2 sample project has the code below in UserManager.Create()

public static UserManager Create(IdentityFactoryOptions<UserManager> options, IOwinContext context) {

  //...etc...

  // --- what does this block do? ---
  var dataProtectionProvider = options.DataProtectionProvider;
  if (dataProtectionProvider != null) {
    manager.UserTokenProvider = new DataProtectorTokenProvider<User>(dataProtectionProvider.Create("ASP.NET Identity"));
  }
  // --------------------------------

  //...etc...

}

的α/β/ RTM身份证件是坏的或不存在的。

The alpha/beta/RTM Identity documentation is bad or non-existent.

这是什么呢?

推荐答案

在以下行保护提供用作令牌提供者/发电机。

The protection provider in the following line is used as a token provider/generator.

manager.UserTokenProvider = new DataProtectorTokenProvider<User>(dataProtectionProvider.Create("ASP.NET Identity"));

它负责生成电子邮件确认令牌或密码重置令牌。如果不设置此行您将无法使用该功能(适当将引发异常)。一个例子可以发现这里。

它的主要目的是提供的一个实施 IDataProtector 接口(通过的创建的方法)的加密和解密数据。在框架此接口的实现是在 DpapiDataProtectionProvider 当应用程序不是由ASP.NET托管应该使​​用。有在网络上其他几个实现(其使用安全目的的机器重要的例子之一)。类有关DataProtectorTokenProvider更多信息,看看在。

Its main purpose is to provide an implementation of the IDataProtector interface (through the Create method) which encrypts and decrypts data. An implementation for this interface in the framework is the DpapiDataProtectionProvider which should be used when the application is not hosted by ASP.NET. There are several other implementations on the web (for example one which uses the machine key for security purposes). class For more information about the DataProtectorTokenProvider have a look at the MSDN documentation.

更新

数据保护文档现已推出。

这篇关于在Identity示例项目DataProtectionProvider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-21 02:51