Authy.AspNetCore 0.1.11-beta

This is a prerelease version of Authy.AspNetCore.
dotnet add package Authy.AspNetCore --version 0.1.11-beta
NuGet\Install-Package Authy.AspNetCore -Version 0.1.11-beta
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Authy.AspNetCore" Version="0.1.11-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Authy.AspNetCore --version 0.1.11-beta
#r "nuget: Authy.AspNetCore, 0.1.11-beta"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Authy.AspNetCore as a Cake Addin
#addin nuget:?package=Authy.AspNetCore&version=0.1.11-beta&prerelease

// Install Authy.AspNetCore as a Cake Tool
#tool nuget:?package=Authy.AspNetCore&version=0.1.11-beta&prerelease

Authy.AspNetCore

Authy.AspNetCore makes it easy for developers to replace the existing TOTP algorithm in asp.net core with Authy.

Authy.AspNetCore is in beta and you may encounter bugs. This project is subject to breaking changes.

Quick Start

Using Authy.AspNetCore is easy. There are several "tricks" used that allow you to use Authy.AspNetCore without requiring any database migrations.

Add authy to your application (Note: If you are using a custom DBContext or IdentityUser class, replace them as needed)
services.AddDefaultIdentity<ApplicationUser>(options => {
    options.Tokens.AuthenticatorTokenProvider = AuthyBuilder.AUTHY_TOKEN_PROVIDER_NAME;
}).AddRoles<IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddAuthy2FA<ApplicationUser>();

services.AddAuthy(new AuthyCredentials("YOUR AUTHY API KEY HERE"));

services.AddHttpClient();
Note: This replaces the existing TOTP algorithm. We may readd the existing TOTP algorithm

Now that you have added Authy.AspNetCore you can create a user as follows (you should verify that the user was created)

//Note: IAuthyCall2FA is registered with DI
private readonly IAuthyCall2FA _authy;

public async Task<IActionResult> OnPostAsync()
{
    var user = await _userManager.GetUserAsync(User);
    if (user == null)
    {
        return NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
    }

    if (!ModelState.IsValid)
    {
        return Page();
    }

    var authyUser = new AuthyUser
    {
        CountryCode = CountryCode,
        PhoneNumber = PhoneNumber,
        Email = user.Email
    };

    var code = await _authy.RegisterUserAsync(authyUser, _userManager, user);
    return RedirectToPage("./EnableAuthenticator");
    return Page();
}

You should not need to modify LoginWith2fa at all unless you want to use Authy OneTouch

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.11-beta 381 8/29/2020
0.1.10-beta 262 8/24/2020
0.1.9-beta 276 8/24/2020
0.1.8-beta 383 8/22/2020
0.1.7-beta 386 8/22/2020
0.1.6-beta 390 8/22/2020
0.1.5-beta 390 8/22/2020
0.1.4-beta 395 8/22/2020
0.1.3-beta 365 8/22/2020
0.1.2-beta 459 8/21/2020
0.1.1-beta 375 8/21/2020
0.1.0-beta 494 8/21/2020