Are there any sample implementation for google authenticator as two factor authentication implementation in addition to sms and email?
Found one sample. Sample Google Authenticator using asp.net
But there are lots of changes while using it with asp.net core.
You can use AspNetCore.Totp. https://github.com/damirkusar/AspNetCore.Totp
It works exactly like GoogleAuthenticator, have a look at the Tests project for the implementation (really simple).
You just have a couple of lines to write to get the qurcode and to validate the pin code:
using AspNetCore.Totp;
...
// To generate the qrcode/setup key
var totpSetupGenerator = new TotpSetupGenerator();
var totpSetup = totpSetupGenerator.Generate("You app name here", "The username", "YourSuperSecretKeyHere", 300, 300);
string qrCodeImageUrl = totpSetup.QrCodeImage;
string manualEntrySetupCode = totpSetup.ManualSetupKey;
// To validate the pin after user input (where pin is an int variable)
var totpValidator = new TotpValidator();
bool isCorrectPIN = totpValidator.Validate("YourSuperSecretKeyHere", pin);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With