DataProtectorTokenProvider Class

Summary

Provides protection and validation of identity tokens.

Syntax

public class DataProtectorTokenProvider : IUserTokenProvider

GitHub

View on GitHub

class Microsoft.AspNet.Identity.DataProtectorTokenProvider

Constructors

DataProtectorTokenProvider(IDataProtectionProvider, IOptions<Microsoft.AspNet.Identity.DataProtectionTokenProviderOptions>)

Initializes a new instance of the DataProtectorTokenProvider&lt;TUser&gt; class.

Arguments:
  • dataProtectionProvider (IDataProtectionProvider) – The system data protection provider.
  • options (IOptions{Microsoft.AspNet.Identity.DataProtectionTokenProviderOptions}) – The configured Microsoft.AspNet.Identity.DataProtectionTokenProviderOptions.
public DataProtectorTokenProvider(IDataProtectionProvider dataProtectionProvider, IOptions<DataProtectionTokenProviderOptions> options)

Methods

CanGenerateTwoFactorTokenAsync<TUser>(Microsoft.AspNet.Identity.UserManager<TUser>, TUser)

Returns a 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.AspNet.Identity.UserManager{{TUser}}) – The Microsoft.AspNet.Identity.UserManager`1 to retrieve user properties from.
  • user ({TUser}) – The TUser the token was generated for.
Return type:

System.Threading.Tasks.Task{System.Boolean}

Returns:

A <see cref=”T: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<TUser>(UserManager<TUser> manager, TUser user)where TUser : class
GenerateAsync<TUser>(System.String, Microsoft.AspNet.Identity.UserManager<TUser>, TUser)

Generates a protected token for the specified user as an asynchronous operation.

Arguments:
  • purpose (System.String) – The purpose the token will be used for.
  • manager (Microsoft.AspNet.Identity.UserManager{{TUser}}) – The Microsoft.AspNet.Identity.UserManager`1 to retrieve user properties from.
  • user ({TUser}) – The TUser the token will be generated from.
Return type:

System.Threading.Tasks.Task{System.String}

Returns:

A <see cref=”T:System.Threading.Tasks.Task`1” /> representing the generated token.

public virtual Task<string> GenerateAsync<TUser>(string purpose, UserManager<TUser> manager, TUser user)where TUser : class
NotifyAsync<TUser>(System.String, Microsoft.AspNet.Identity.UserManager<TUser>, TUser)

Creates a notification for the specified user based on the supplied token as an asynchronous operation.

Arguments:
  • token (System.String) – The token to generate notifications for.
  • manager (Microsoft.AspNet.Identity.UserManager{{TUser}}) – The Microsoft.AspNet.Identity.UserManager`1 to retrieve user properties from.
  • user ({TUser}) – The TUser the token was generated for.
Return type:

System.Threading.Tasks.Task

Returns:

A <see cref=”T:System.Threading.Tasks.Task`1” /> that represents the asynchronous notification.

public virtual Task NotifyAsync<TUser>(string token, UserManager<TUser> manager, TUser user)where TUser : class
ValidateAsync<TUser>(System.String, System.String, Microsoft.AspNet.Identity.UserManager<TUser>, TUser)

Validates the protected token for the specified user and purpose 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.AspNet.Identity.UserManager{{TUser}}) – The Microsoft.AspNet.Identity.UserManager`1 to retrieve user properties from.
  • user ({TUser}) – The TUser the token was generated for.
Return type:

System.Threading.Tasks.Task{System.Boolean}

Returns:

A <see cref=”T: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<TUser>(string purpose, string token, UserManager<TUser> manager, TUser user)where TUser : class

Properties

Name()

Gets the name of this instance.

Return type:System.String
public string Name { get; }
Options()

Gets the Microsoft.AspNet.Identity.DataProtectionTokenProviderOptions for this instance.

Return type:Microsoft.AspNet.Identity.DataProtectionTokenProviderOptions
protected DataProtectionTokenProviderOptions Options { get; }
Protector()

Gets the IDataProtector for this instance.

Return type:IDataProtector
protected IDataProtector Protector { get; }