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.
Enable Authy in your Twilio Account if you don't have one already, and then connect it to your Twilio account.
This project is built using Install .NET Core, which will need to be installed before continuing.
-
First clone this repository and
cd
into it.git clone https://github.com/TwilioDevEd/account-security-csharp.git cd account-security-csharp
-
Install the dependencies.
cd src/AccountSecurity dotnet restore
You can either install it or run it in a docker container.
-
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
-
Make sure your
DefaultConnection
connection string is correct for your SQL Server installation. (You may need to change theServer
tolocalhost\\SQLEXPRESS
if running MSSQL Server Express on Windows.) -
Run the database migrations:
dotnet ef database update -v
-
Set your Authy App API Key in your
appsettings.json
asAuthyApiKey
which should be found under your Authy App Settings. -
Run the server.
dotnet run --environment development
-
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
- No warranty expressed or implied. Software is as is.
- MIT License
- Lovingly crafted by Twilio Developer Education.