DataProtectorTokenProvider<TUser> Class¶
Provides protection and validation of identity tokens.
- Namespace
Microsoft.AspNetCore.Identity
- Assemblies
- Microsoft.AspNetCore.Identity
Syntax¶
public class DataProtectorTokenProvider<TUser> : IUserTwoFactorTokenProvider<TUser> where TUser : class
-
class
Microsoft.AspNetCore.Identity.
DataProtectorTokenProvider<TUser>
¶
Constructors¶
-
DataProtectorTokenProvider
(Microsoft.AspNetCore.DataProtection.IDataProtectionProvider, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Identity.DataProtectionTokenProviderOptions>)¶ Initializes a new instance of the
Microsoft.AspNetCore.Identity.DataProtectorTokenProvider`1
class.Arguments: - dataProtectionProvider (Microsoft.AspNetCore.DataProtection.IDataProtectionProvider) – The system data protection provider.
- options (Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Identity.DataProtectionTokenProviderOptions>) – The configured
Microsoft.AspNetCore.Identity.DataProtectionTokenProviderOptions
.
public DataProtectorTokenProvider(IDataProtectionProvider dataProtectionProvider, IOptions<DataProtectionTokenProviderOptions> options)
-
Methods¶
-
CanGenerateTwoFactorTokenAsync
(Microsoft.AspNetCore.Identity.UserManager<TUser>, TUser)¶ Returns a
System.Boolean
indicating whether a token generated by this instance can be used as a Two Factor Authentication token as an asynchronous operation.Arguments: - manager (Microsoft.AspNetCore.Identity.UserManager<TUser>) – The
Microsoft.AspNetCore.Identity.UserManager`1
to retrieve user properties from. - user (TUser) – The <em>TUser</em> the token was generated for.
Return type: System.Threading.Tasks.Task<System.Boolean>
Returns: A
System.Threading.Tasks.Task`1
that represents the result of the asynchronous query, containing true if a token generated by this instance can be used as a Two Factor Authentication token, otherwise false.public virtual Task<bool> CanGenerateTwoFactorTokenAsync(UserManager<TUser> manager, TUser user)
- manager (Microsoft.AspNetCore.Identity.UserManager<TUser>) – The
-
GenerateAsync
(System.String, Microsoft.AspNetCore.Identity.UserManager<TUser>, TUser)¶ Generates a protected token for the specified <em>user</em> as an asynchronous operation.
Arguments: - purpose (System.String) – The purpose the token will be used for.
- manager (Microsoft.AspNetCore.Identity.UserManager<TUser>) – The
Microsoft.AspNetCore.Identity.UserManager`1
to retrieve user properties from. - user (TUser) – The <em>TUser</em> the token will be generated from.
Return type: System.Threading.Tasks.Task<System.String>
Returns: A
System.Threading.Tasks.Task`1
representing the generated token.public virtual Task<string> GenerateAsync(string purpose, UserManager<TUser> manager, TUser user)
-
ValidateAsync
(System.String, System.String, Microsoft.AspNetCore.Identity.UserManager<TUser>, TUser)¶ Validates the protected <em>token</em> for the specified <em>user</em> and <em>purpose</em> as an asynchronous operation.
Arguments: - purpose (System.String) – The purpose the token was be used for.
- token (System.String) – The token to validate.
- manager (Microsoft.AspNetCore.Identity.UserManager<TUser>) – The
Microsoft.AspNetCore.Identity.UserManager`1
to retrieve user properties from. - user (TUser) – The <em>TUser</em> the token was generated for.
Return type: System.Threading.Tasks.Task<System.Boolean>
Returns: A
System.Threading.Tasks.Task`1
that represents the result of the asynchronous validation, containing true if the token is valid, otherwise false.public virtual Task<bool> ValidateAsync(string purpose, string token, UserManager<TUser> manager, TUser user)
-
Properties¶
-
Microsoft.AspNetCore.Identity.DataProtectorTokenProvider<TUser>.
Name
¶ Gets the name of this instance.
Return type: System.String Returns: The name of this instance. public string Name { get; }
-
Microsoft.AspNetCore.Identity.DataProtectorTokenProvider<TUser>.
Options
¶ Gets the
Microsoft.AspNetCore.Identity.DataProtectionTokenProviderOptions
for this instance.Return type: Microsoft.AspNetCore.Identity.DataProtectionTokenProviderOptions Returns: The Microsoft.AspNetCore.Identity.DataProtectionTokenProviderOptions
for this instance.protected DataProtectionTokenProviderOptions Options { get; }
-
Microsoft.AspNetCore.Identity.DataProtectorTokenProvider<TUser>.
Protector
¶ Gets the
Microsoft.AspNetCore.DataProtection.IDataProtector
for this instance.Return type: Microsoft.AspNetCore.DataProtection.IDataProtector Returns: The Microsoft.AspNetCore.DataProtection.IDataProtector
for this instance.protected IDataProtector Protector { get; }
-