Skip to content
This repository has been archived by the owner on Sep 14, 2021. It is now read-only.

TwilioDevEd/account-security-csharp

Repository files navigation

Twilio

Important Notice

For new development, we encourage you to use the Verify API instead of the Authy API. The Verify API is an evolution of the Authy API with continued support for SMS, voice, and email one-time passcodes, an improved developer experience and new features.

Please visit the Verify Quickstarts Page to get started with the Verify API. Thank you!

Two-Factor Authentication with ASP.NET Core and Authy

Here you will learn how to create a login system for ASP.NET Core applications secured with 2FA using Authy.

Learn more about this code in our docs.

Quickstart

Create an Authy app

Enable Authy in your Twilio Account if you don't have one already, and then connect it to your Twilio account.

Local development

This project is built using .NET Core, which will need to be installed before continuing.

  1. First clone this repository and cd into it.

    git clone https://github.com/TwilioDevEd/account-security-csharp.git
    cd account-security-csharp 
  2. Install the dependencies.

    cd src/AccountSecurity
    dotnet restore 

MSSQL Server

You can either install it or run it in a docker container.

  • Install MSSQL Server Express

  • Run in a docker container:

    docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong(!)Password' -p 1433:1433 --name mssql -d microsoft/mssql-server-linux:latest

  1. Make sure your DefaultConnection connection string is correct for your SQL Server installation. (You may need to change the Server to localhost\\SQLEXPRESS if running MSSQL Server Express on Windows.)

  2. Install the Entity Framework tool:

    dotnet tool install --global dotnet-ef --version 3.1.4
  3. Run the database migrations:

    dotnet ef database update -v
  4. Set your Authy App API Key in your appsettings.json as AuthyApiKey which should be found under your Authy App Settings.

  5. Run the server.

    dotnet run --environment development 
  6. Expose your application to the wider internet using ngrok. You can click here for more details. This step is important because the application won't work as expected if you run it through localhost.

    ngrok http 5000 

Once ngrok is running, open up your browser and go to your ngrok URL. It will look something like this: http://9a159ccf.ngrok.io

Meta

  • No warranty expressed or implied. Software is as is.
  • MIT License
  • Lovingly crafted by Twilio Developer Education.

About

Two-Factor Authentication with ASP.NET Core and Authy

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages