You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 15/umbraco-cms/reference/security/two-factor-authentication.md
+68-24
Original file line number
Diff line number
Diff line change
@@ -6,27 +6,41 @@ description: >-
6
6
7
7
# Two-factor Authentication
8
8
9
-
Two-factor authentication (2FA) for Umbraco members is activated by implementing an `ITwoFactorProvider` interface and registering the implementation. The implementation can use third-party packages to archive for example support for authentication apps like Microsoft- or Google Authentication App.
9
+
This article includes guides for implementing two-factor authentication options for both backoffice users and website members:
10
+
11
+
*[Two-Factor Authentication for Members](#two-factor-authentication-for-members)
12
+
*[Two-Factor Authentication for Users](#two-factor-authentication-for-users)
13
+
14
+
Two-factor authentication (2FA) for Umbraco Users and Members is activated by implementing an `ITwoFactorProvider` interface and registering the implementation. The implementation can use third-party packages to support authentication apps like the Microsoft- or Google Authentication Apps.
10
15
11
16
{% hint style="info" %}
12
17
If you are using [Umbraco Cloud](https://umbraco.com/products/umbraco-cloud/), you can enable multi-factor authentication in Umbraco ID. For more information, see the [Multi-Factor Authentication](https://docs.umbraco.com/umbraco-cloud/set-up/multi-factor-authentication-on-cloud) article.
13
18
{% endhint %}
14
19
15
20
## Two-factor authentication for Members
16
21
17
-
Since Umbraco does not control how the UI is for member login and profile edit. The UI for 2FA is shipped as part of the Partial View snippets. These can be used as a starting point, before styling the page as you would like.
22
+
The following guide will take you through implementing an option for your website members to enable two-factor authentication.
23
+
24
+
{% hint style="info" %}
25
+
A setup for members needs to be implemented on your website in order for you to follow this guide. This setup should include:
26
+
27
+
* Login and logout options.
28
+
* Public access restriction configured on at least 1 content item.
18
29
19
-
### Example implementation for Authenticator Apps for Members
30
+
[Learn more about setting up a members section in Umbraco.](../../tutorials/members-registration-and-login.md)
31
+
{% endhint %}
20
32
21
-
In the following example, we will use the [GoogleAuthenticator NuGet Package](https://www.nuget.org/packages/GoogleAuthenticator/).
33
+
As an example, the guide will use the [GoogleAuthenticator NuGet Package](https://www.nuget.org/packages/GoogleAuthenticator/). This package works for both Google and Microsoft authenticator apps. It can be used to generate the QR code needed to activate the app for the website.
22
34
23
-
Despite the name, this package works for both Google and Microsoft authenticator apps. It can be used to generate the QR code needed to activate the app for the website.
35
+
1. Install the GoogleAuthenticator Nuget Package on your project.
36
+
2. Create a new file in your project: `UmbracoAppAuthenticator.cs`.
37
+
3. Update the file with the following code snippet.
First, we create a model with the information required to set up the 2FA provider. Then we implement the `ITwoFactorProvider` with the use of the `TwoFactorAuthenticator` from the GoogleAuthenticator NuGet package.
132
+
{% endcode %}
118
133
119
-
Now we need to register the `UmbracoAppAuthenticator` implementation. This can be done on the `IUmbracoBuilder` in your startup or a composer.
134
+
4. Update `namespace` on line 7 to match your project.
135
+
5. Customize the `applicationName` variable on line 64.
136
+
6. Create a Composer and register the `UmbracoAppAuthenticator` implementation as shown below.
@@ -135,15 +153,24 @@ public class UmbracoAppAuthenticatorComposer : IComposer
135
153
}
136
154
}
137
155
```
156
+
138
157
{% endcode %}
139
158
140
-
At this point, the 2FA is active, but no members have set up 2FA yet. The setup of 2FA depends on the type. In the case of App Authenticator, we will add the following to our **view** showing the edit profile of the member.
159
+
At this point, the 2FA is active, but no members have set up 2FA yet. The setup of 2FA depends on the type. In the case of App Authenticator, add the following to the **view** showing the edit profile of the member.
160
+
161
+
7. Add or choose a members-only page that should have the two-factor authentication setup.
162
+
* The page needs to be behind the public access.
163
+
* The page should **not** be using strongly types models.
@@ -186,11 +217,24 @@ At this point, the 2FA is active, but no members have set up 2FA yet. The setup
186
217
}
187
218
```
188
219
189
-
In this razor-code sample, we get the current member's unique key and list all registered `ITwoFactorProvider` implementations.
220
+
{% endcode %}
221
+
222
+
10. Update the `@using` in line 4 to match the namespace of your project.
223
+
11.[Optional] Customize the text fields and buttons to match your websites tone of voice (lines 33-39).
224
+
225
+

226
+
227
+
### Test the set up for Members
228
+
229
+
1. Login to the website using a test member.
230
+
2. Navigate to the page where the QR code was added.
231
+
3. Scan the QR code and add the verification code.
232
+
4. Logout of the website.
233
+
5. Login and verify that it asks for the two factor authentication.
190
234
191
-
If the `setupData` is `null` for the specified `providerName` it means the provider is already set up. In this case, we show a disable button. Otherwise, we check the type and show the UI for how to set up the App Authenticator. We will show the QR Code and an input field to validate the code from the App Authenticator.
235
+
You can also check that the **Two-factor Authentication** option is checked on the member in the Umbraco backoffice.
192
236
193
-
The last part required is to use the `Login` Partial View snippet.
237
+

194
238
195
239
### Notification when 2FA is requested for a member
0 commit comments