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.
<PackageVersion Include="Authy.AspNetCore" Version="0.1.11-beta" />
                    
Directory.Packages.props
<PackageReference Include="Authy.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version 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.
#:package Authy.AspNetCore@0.1.11-beta
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Authy.AspNetCore&version=0.1.11-beta&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Authy.AspNetCore&version=0.1.11-beta&prerelease
                    
Install as a Cake Tool

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.