I needed to easily rollout Two Factor authentication on Umbraco, so I decided to take the Umbraco Documentation and create a package to make installation simple for Umbraco 9.5+ sites.
I've changed some of the code to be extensions on the IUmbracoBuilder rather than a composer, added the manual key to the dialog modal and added configuration for each environment.
Nuget
https://www.nuget.org/packages/punkTwoFactor/
Install-Package punkTwoFactor Installation
Install the nuget package, then add the following section to your appsettings.json:
"punkTwoFactor": { "ProviderName": "Two Factor Authentication", "Issuer": "Two Factor Authentication - Dev", "BackOfficeView": "..\\App_Plugins\\punkTwoFactor\\twoFactorProviderGoogleAuthenticator.html" } Add the following code block within your ConfigureServices section above the Umbraco setup:
services.Configure<TwoFactorConfig>(_config.GetSection("punkTwoFactor")); TwoFactorConfig twoFactorConfiguration = new(); _config.GetSection("punkTwoFactor").Bind(twoFactorConfiguration); Now add the "AddBackOfficeTwoFactorAuthentication" extension to the Umbraco setup.
services .AddUmbraco(_env, _config) .AddBackOffice() .AddWebsite() .AddBackOfficeTwoFactorAuthentication(twoFactorConfiguration) .Build(); Usage
Click on your profile picture in Umbraco:

Click the Configure Two Factor button:

You'll then see the familar QR code, with the additional Manual Input key:

Once you add this QR code to your authenticator, you can enter the code and you're good!
You'll now be configured to use Two Factor Authentication on your account! :)
GitHub
https://github.com/garpunkal/punkTwoFactor
Contact
If you need any help, give me a shout on twitter.



Top comments (0)