Skip to content

Commit 5739b08

Browse files
committed
Merge branch 'main' into cms15/twoFactor
2 parents ec98452 + 6955de0 commit 5739b08

File tree

53 files changed

+386
-338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+386
-338
lines changed

10/umbraco-forms/installation/install.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ Umbraco contains the **Forms** section, by default. You will see a similar inter
1515

1616
To install the Umbraco Forms package (**Umbraco.Forms**), follow these steps:
1717

18-
1. Run the following command on a command prompt of your choice:
18+
1. Identify the Umbraco CMS version your project is running.
19+
2. Find a compatible version of Umbraco Forms that matches your Umbraco CMS version. A list of Umbraco Forms versions can be found on [nuget.org](https://www.nuget.org/packages/Umbraco.Forms#versions-body-tab).
20+
3. Run the following command on a command prompt of your choice, replacing `<version_number>` with the appropriate version identified above:
1921

2022
```
21-
dotnet add package Umbraco.Forms
23+
dotnet add package Umbraco.Forms --version <version_number>
2224
```
23-
2. Restart the web application using the following command:
25+
4. Restart the web application using the following command:
2426
2527
```
2628
dotnet run

13/umbraco-cms/reference/security/external-login-providers.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,19 @@ public class ProviderBackOfficeExternalLoginProviderOptions : IConfigureNamedOpt
255255
// Choose to automatically redirect to the external login provider
256256
// effectively removing the login button.
257257
options.AutoRedirectLoginToExternalProvider = false;
258+
259+
// [OPTIONAL]
260+
// Set the button color and look.
261+
options.ButtonColor = UuiButtonColor.Positive;
262+
options.ButtonLook = UuiButtonLook.Primary;
258263
}
259264
}
260265
```
261266
{% endcode %}
262267

263268
**Icons**
264269

265-
If you want to use a custom icon for the login button, you need to add the icon to the Umbraco backoffice. You can do this by adding the icon to the `~/App_Plugins/MyPlugin/BackOffice/Icons` folder. The icon should be a SVG file. The icon should be named the same as the icon name you specify in the `options.Icon` property.
270+
If you want to use a custom icon for the login button, you need to add the icon to the Umbraco backoffice. You can do this by adding the icon to the `~/App_Plugins/MyPlugin/BackOffice/Icons` folder. The icon should be an SVG file. The icon should be named the same as the icon name you specify in the `options.Icon` property.
266271

267272
{% hint style="info" %}
268273
You can use the [Umbraco Icon Picker](../../fundamentals/data/defining-content/README.md#adding-icons-to-the-document-type) to see available icons.
@@ -362,7 +367,7 @@ The `CustomBackofficeView` allows for specifying a JavaScript module to render a
362367
* You want to display something different where external login providers are listed: in the login screen vs the backoffice panel vs on the logged-out screen. This same view will render in all of these cases but you can use the current route parameters to customize what is shown.
363368
* You want to change how the button interacts with the external login provider. For example, instead of having the site redirect on button-click, you want to open a popup window to load the external login provider.
364369

365-
The path to the custom view is a virtual path, like this example: `"~/App_Plugins/MyPlugin/BackOffice/my-external-login.js"`.
370+
The path to the custom view is a virtual path, like this example: `"/App_Plugins/MyPlugin/BackOffice/my-external-login.js"`.
366371

367372
When a custom view is specified it is 100% up to this module to perform all required logic.
368373

@@ -374,7 +379,7 @@ The module should define a Custom Element and export it as default. The Custom E
374379
* `userViewState`: The current view state of the user. This can be one of the following values:
375380
* `loggingIn`: The user is on the login screen.
376381
* `loggedIn`: The user is on the backoffice panel.
377-
* `loggedOut`: The user clicked the logout button and is on the logged-out screen.
382+
* `loggedOut`: The user clicks the logout button and is on the logged-out screen.
378383
* `timedOut`: The user's session has timed out and they are on the timed-out screen.
379384

380385
**TypeScript**
@@ -396,7 +401,7 @@ interface IExternalLoginCustomViewElement {
396401

397402
**Examples**
398403

399-
The Custom Element can be implemented in a number of ways with many different libraries or frameworks. The following examples show how to make a button appear and redirect to the external login provider. You will learn how to use the `externalLoginUrl` property to redirect to the external login provider. The login form should look like this when you open Umbraco:
404+
The Custom Element can be implemented in several ways with many different libraries or frameworks. The following examples show how to make a button appear and redirect to the external login provider. You will learn how to use the `externalLoginUrl` property to redirect to the external login provider. The login form should look like this when you open Umbraco:
400405

401406
![Login form with custom external login button](./images/external-login-provider-javascript.png)
402407

@@ -475,7 +480,7 @@ class MyLitView extends LitElement {
475480
providerName: { type: String },
476481
displayName: { type: String },
477482
externalLoginUrl: { type: String },
478-
userViewState: { type: String }
483+
userViewState: { type: String, state: true }
479484
};
480485
}
481486

@@ -514,7 +519,7 @@ export default MyLitView;
514519

515520
### Static extension class
516521

517-
The extension class is required to extend on the default authentication implementation in Umbraco CMS. A generic example of such extension class can be seen below.
522+
The extension class is required to extend the default authentication implementation in Umbraco CMS. A generic example of such an extension class can be seen below.
518523

519524
{% tabs %}
520525
{% tab title="User Authentication" %}
Loading

13/umbraco-cms/reference/security/two-factor-authentication.md

+73-33
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ This article includes guides for implementing two-factor authentication options
1111
* [Two-Factor Authentication for Members](#two-factor-authentication-for-members)
1212
* [Two-Factor Authentication for Users](#two-factor-authentication-for-users)
1313

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.
15+
1416
{% hint style="info" %}
1517

1618
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.
@@ -19,8 +21,6 @@ If you are using [Umbraco Cloud](https://umbraco.com/products/umbraco-cloud/), y
1921

2022
## Two-factor authentication for Members
2123

22-
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 support authentication apps like the Microsoft- or Google Authentication Apps.
23-
2424
The following guide will take you through implementing an option for your website members to enable two-factor authentication.
2525

2626
{% hint style="info" %}
@@ -224,7 +224,7 @@ At this point, the 2FA is active, but no members have set up 2FA yet. The setup
224224

225225
![The QR Code is shown along with a field to enter a value to set up the two factor authentication.](images/2fa-Members-QR-code.png)
226226

227-
### Test the set up
227+
### Test the set up for Members
228228

229229
1. Login to the website using a test member.
230230
2. Navigate to the page where the QR code was added.
@@ -242,11 +242,19 @@ When a 2FA login is requested for a member, the `MemberTwoFactorRequestedNotific
242242

243243
## Two-factor authentication for Users
244244

245-
Umbraco controls how the UI is for user login and user edits, but will still need a view for configuring each 2FA provider.
245+
The following guide will take you through implementing an option for backoffice users to enable two-factor authentication.
246+
247+
This guide will not cover setting up the UI for user login and edits as this is handled elsewhere in the CMS.
246248

247249
### Example implementation for Authenticator Apps for Users
248250

249-
In the following example, we will use the [GoogleAuthenticator NuGet Package](https://www.nuget.org/packages/GoogleAuthenticator/). 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.
251+
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.
252+
253+
1. Install the GoogleAuthenticator Nuget Package on your project.
254+
2. Create a new file in your project: `TwoFactorAuthInfo.cs`.
255+
3. Update the file with the following code snippet.
256+
257+
{% code title="TwoFactorAuthInfo.cs" lineNumbers="true" %}
250258

251259
```csharp
252260
using System.Runtime.Serialization;
@@ -257,6 +265,9 @@ using Umbraco.Cms.Core.Services;
257265

258266
namespace My.Website;
259267

268+
/// <summary>
269+
/// Create a model with the information required to set up the 2FA provider
270+
/// </summary>
260271
[DataContract]
261272
public class TwoFactorAuthInfo
262273
{
@@ -268,7 +279,7 @@ public class TwoFactorAuthInfo
268279
}
269280

270281
/// <summary>
271-
/// App Authenticator implementation of the ITwoFactorProvider
282+
/// Implement the `ITwoFactorProvider` with the use of the `TwoFactorAuthenticator` from the GoogleAuthenticator NuGet package
272283
/// </summary>
273284
public class UmbracoUserAppAuthenticator : ITwoFactorProvider
274285
{
@@ -307,8 +318,9 @@ public class UmbracoUserAppAuthenticator : ITwoFactorProvider
307318

308319
ArgumentNullException.ThrowIfNull(user);
309320

321+
var applicationName = "My application name";
310322
var twoFactorAuthenticator = new TwoFactorAuthenticator();
311-
SetupCode setupInfo = twoFactorAuthenticator.GenerateSetupCode("My application name", user.Username, secret, false);
323+
SetupCode setupInfo = twoFactorAuthenticator.GenerateSetupCode(applicationName, user.Username, secret, false);
312324
return Task.FromResult<object>(new TwoFactorAuthInfo()
313325
{
314326
QrCodeSetupImageUrl = setupInfo.QrCodeSetupImageUrl,
@@ -333,17 +345,19 @@ public class UmbracoUserAppAuthenticator : ITwoFactorProvider
333345
}
334346
```
335347

336-
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.
348+
{% endcode %}
349+
350+
4. Update `namespace` on line 7 to match your project.
351+
5. Customize the `applicationName` variable on line 59.
352+
6. Create a new file in your project: `UmbracoAppAuthenticatorComposer.cs`.
353+
7. Implement a new composer and register the `UmbracoAppAuthenticator` implementation as shown below.
337354

338-
Now we need to register the `UmbracoUserAppAuthenticator` implementation and the view to show to set up this provider. This can be done on the `IUmbracoBuilder` in your startup or a composer.
355+
{% code title="UmbracoAppAuthenticatorComposer.cs" lineNumbers="true" %}
339356

340357
```csharp
341-
using Microsoft.Extensions.DependencyInjection;
342358
using Umbraco.Cms.Core.Composing;
343-
using Umbraco.Cms.Core.DependencyInjection;
344359
using Umbraco.Cms.Core.Security;
345360
using Umbraco.Cms.Web.BackOffice.Security;
346-
using Umbraco.Extensions;
347361

348362
namespace My.Website;
349363

@@ -363,7 +377,18 @@ public class UmbracoAppAuthenticatorComposer : IComposer
363377
}
364378
```
365379

366-
Now we need to create the view we configured, in the path we choose.
380+
{% endcode %}
381+
382+
8. Update the `namespace` on line 5 to match your project.
383+
384+
In the composer above, a view for the two-factor authentication is configured. This view needs to be created.
385+
386+
9. Open the project directory.
387+
10. Locate or create the path as defined in the composer above: `App_Plugins\TwoFactorProviders`.
388+
11. Create a new file: `twoFactorProviderGoogleAuthenticator.html`.
389+
12. Open the file and add the following markup:
390+
391+
{% code title="twoFactorProviderGoogleAuthenticator.html" lineNumbers="true" %}
367392

368393
```html
369394
<div ng-controller="CustomCode.TwoFactorProviderGoogleAuthenticator as vm">
@@ -430,19 +455,14 @@ Now we need to create the view we configured, in the path we choose.
430455
</div>
431456
```
432457

433-
As this view uses an angular controller, we need to create that class and configure it in the `package.manifest`.
458+
{% endcode %}
434459

435-
In `package.manifest`, we point to the path of the angular controller that we are creating in the next step.
460+
The view above uses an Angular controller, which needs to be created and configured in a `package.manifest` file.
436461

437-
```json
438-
{
439-
"javascript": [
440-
"~/App_Plugins/TwoFactorProviders/twoFactorProviderGoogleAuthenticator.controller.js"
441-
]
442-
}
443-
```
462+
13. Create a new file: `App_Plugins/TwoFactorProviders/twoFactorProviderGoogleAuthenticator.controller.js`.
463+
14. Add the following code:
444464

445-
And we create the controller in that location:
465+
{% code title="twoFactorProviderGoogleAuthenticator.controller.js" lineNumbers="true" %}
446466

447467
```javascript
448468
!(function () {
@@ -514,29 +534,49 @@ And we create the controller in that location:
514534
})();
515535
```
516536
517-
At this point, the 2FA is active, but no users have set up 2FA yet.
537+
{% endcode %}
538+
539+
15. Create a new file: `App_Plugins\TwoFactorProviders\package.manifest`.
540+
16. Point to the path of the Angular controller created above:
518541
519-
Each user can now enable the configured 2fa providers on their user. This can be done from the user panel by clicking the user avatar.
542+
{% code title="package.manifest" lineNumbers="true" %}
543+
544+
```json
545+
{
546+
"javascript": [
547+
"~/App_Plugins/TwoFactorProviders/twoFactorProviderGoogleAuthenticator.controller.js"
548+
]
549+
}
550+
```
551+
552+
{% endcode %}
553+
554+
At this point, the 2FA is active, but no users have set it up.
555+
556+
### Test the set up for Users
557+
558+
Each user can now enable the configured 2fa providers on their user.
559+
560+
1. Access the Umbraco backoffice.
561+
2. Click the user avatar in the top-right corner.
520562
521563
![User panel](images/user-panel.png)
522564
523-
When clicking the `Configure Two-Factor` button, a new panel is shown, listing all enabled two-factor providers.
565+
3. Select `Configure Two-Factor` button to open a new panel listing all enabled two-factor providers.
524566
525567
![Configure 2fa](images/configure-2fa.png)
526568
527-
When clicking `Enable` on one of these, the configured view for the specific provider will be shown
569+
4. Select `Enable` to show the configured view.
528570
529571
![Enable 2fa](images/enable-2fa.png)
530572
531-
When the authenticator is enabled correctly, a disable button is shown instead.
573+
5. Follow the instructions to configure 2FA.
532574
533-
![Disable 2fa](images/disable-2fa.png)
534-
535-
To disable the two-factor authentication on your user, it is required to enter the verification code. Otherwise, admins are allowed to disable providers on other users.
575+
When the authenticator is enabled correctly, a disable button is shown instead.
536576
537-
![Verify disable](images/verify-disable.png)
577+
![Disable 2fa](images/2fa-user-disable.png)
538578
539-
If the code is correct, the provider is disabled.
579+
To disable the two-factor authentication on your user, it is required to enter the verification code.
540580
541581
### Notification when 2FA is requested for a user
542582

13/umbraco-forms/installation/install.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ Umbraco contains the **Forms** section, by default. You will see a similar inter
1414

1515
To install the Umbraco Forms package (**Umbraco.Forms**), follow these steps:
1616

17-
1. Run the following command on a command prompt of your choice:
18-
19-
```
20-
dotnet add package Umbraco.Forms
21-
```
22-
23-
2. Restart the web application using the following command:
24-
25-
```
26-
dotnet run
27-
```
17+
1. Identify the Umbraco CMS version your project is running.
18+
2. Find a compatible version of Umbraco Forms that matches your Umbraco CMS version. A list of Umbraco Forms versions can be found on [nuget.org](https://www.nuget.org/packages/Umbraco.Forms#versions-body-tab).
19+
3. Run the following command on a command prompt of your choice, replacing `<version_number>` with the appropriate version identified above:
20+
21+
```
22+
dotnet add package Umbraco.Forms --version <version_number>
23+
```
24+
4. Restart the web application using the following command:
25+
26+
```
27+
dotnet run
28+
```
2829
2930
## Start Building Forms
3031

0 commit comments

Comments
 (0)