问题描述
我发现它在我的Startup.cs文件中ConfigureServices默认的Visual Studio 2015年asp.net 5项目。
I found it in my Startup.cs file in ConfigureServices in default Visual Studio 2015 asp.net 5 project.
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<AuthorizationDbContext>()
.AddDefaultTokenProviders();
这是什么究竟,以及如何使用这些默认供应商?它配置所有基于令牌的认证给我吗?我在哪里可以阅读更多关于它?
What does it exactly do and how to use those "default providers"? Does it configure all token-based authentication for me? Where can I read more about it?
推荐答案
尽管他们的名字,令牌提供者无关令牌认证:它们是专门用来生成帐户操作的不透明标记(如密码重置或电子邮件的变化)和双因素身份验证。
Despite their name, the token providers have nothing to do with token authentication: they are exclusively used to generate opaque tokens for account operations (like password reset or email change) and two-factor authentication.
目前有3内置提供商:
-
DataProtectorTokenProvider
:顾名思义,它使用的数据块保护(机键'等价于ASP.NET 1.0的核心)连载,以后可以由服务器加密的反序列化令牌。
DataProtectorTokenProvider
: as the name suggests, it uses the data protection block (machine keys' equivalent in ASP.NET Core 1.0) to serialize encrypted tokens that can later be deserialized by the server.
EmailTokenProvider
和 PhoneNumberTokenProvider
:这些供应商都源于 TotpSecurityStampBasedTokenProvider
,它实现了基于时间的一次性密码算法
( TOTP),设计制作可在手机短信或电子邮件发送用户友好和短令牌的协议。
EmailTokenProvider
and PhoneNumberTokenProvider
: these providers are derived from TotpSecurityStampBasedTokenProvider
, which implements the Time-based One-time Password Algorithm
(TOTP), a protocol designed to produce user-friendly and short tokens that can be sent in a SMS or in an email.
ASP.NET 1.0的核心并没有提供原生令牌认证支持(仅令牌验证支持:不能制作自己的令牌)。你可以阅读这些所谓职位的详细信息:
ASP.NET Core 1.0 doesn't offer native token authentication support (only token validation is supported: you can't produce your own tokens). You can read these SO posts for more information:
- JWT认证。
- 。
在ASP.NET 5
- Simple JWT authentication in ASP.NET Core 1.0 Web API.
- Web API Authentication in ASP.NET 5.
- Configure the authorization server endpoint.
这篇关于AddDefaultTokenProviders - 那是什么,以及如何使用这些&QUOT;默认提供&QUOT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!