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: 13/umbraco-cms/tutorials/add-microsoft-entra-id-authentication.md
+49-12Lines changed: 49 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,23 @@ It is still possible to use other [External Login Providers](../reference/securi
22
22
23
23
## Step 1: Configure Entra ID
24
24
25
-
Before your applications can interact with Entra ID, they must be registered with a tenant that you manage. This can be either an Entra ID (Azure AD) tenant, or an Entra ID B2C (Azure AD B2C) tenant. For more information on creating an Azure AD B2C tenant, see [Microsoft's Tutorial: Create an Azure Active Directory B2C tenant](https://learn.microsoft.com/en-us/azure/active-directory-b2c/tutorial-create-tenant).
25
+
Before your applications can interact with Entra ID, they must be registered with a tenant that you manage. This can be either an Entra ID (Azure AD) tenant or an Entra ID B2C (Azure AD B2C) tenant. For more information on creating an Azure AD B2C tenant, see [Microsoft's Tutorial: Quickstart: Use your Azure subscription to create an external tenant](https://learn.microsoft.com/en-us/entra/external-id/customers/quickstart-tenant-setup).
26
+
27
+
Follow these steps to register your web application with your Entra tenant and configure it for member sign-in:
28
+
29
+
1. Follow the instructions in [Register an application in Microsoft Entra ID](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app?tabs=client-secret) using the [Microsoft Entra admin center](https://entra.microsoft.com/).
30
+
31
+
2. On the **App Registrations** screen, copy the **Application (Client) ID** value. You will need this in your code later.
4. Add a new client secret and copy the generated **Value**. You will use this in your code as well.
37
+
38
+
39
+
5. Return to the **Overview** screen and click **Add a Redirect URI**.
40
+
41
+
6. Add full URLs for all of your applicable environments (local, dev, live, etc.) with the path `/umbraco-b2c-members-signin` appended. For example, `https://mysite.com/umbraco-b2c-members-signin`.
26
42
27
43
## Step 2: Install the NuGet package
28
44
@@ -59,9 +75,11 @@ public class EntraIDB2CMembersExternalLoginProviderOptions : IConfigureNamedOpti
// You can modify the Member's groups based on the Claims returned in the external login info.
114
+
93
115
},
94
116
OnExternalLogin= (user, loginInfo) =>
95
117
{
96
-
//Customize the Member before it is saved whenever they have
118
+
//You can also update the Member before it is saved whenever they have
97
119
// logged in with the external provider.
98
-
// Sync the Members name based on the Claims returned
99
-
// in the external login info
120
+
// For example, re-sync the Member's name based on the Claims returned in the external login info
100
121
101
-
//Returns a boolean indicating if sign-in should continue or not.
122
+
//Return a boolean indicating if sign-in should continue or not.
102
123
returntrue;
103
124
}
104
125
};
@@ -107,6 +128,12 @@ public class EntraIDB2CMembersExternalLoginProviderOptions : IConfigureNamedOpti
107
128
```
108
129
{% endcode %}
109
130
131
+
{% hint style="info" %}
132
+
133
+
With **autolinking**, if a visitor uses **Sign in with Microsoft** and their email matches a member, that member is signed in. If no matching member exists, a new one is created. By default, it isn’t assigned to any groups.
134
+
135
+
{% endhint %}
136
+
110
137
2. Create a new static extension class called `MemberAuthenticationExtensions.cs`.
@@ -159,7 +186,15 @@ public static class MemberAuthenticationExtensions
159
186
{% endcode %}
160
187
161
188
{% hint style="info" %}
189
+
162
190
Ensure to replace `YOURCLIENTID` and `YOURCLIENTSECRET` in the code with the values from the Entra ID tenant. If Entra ID is configured to use accounts in the organizational directory only (single tenant registration), you must specify the Token and Authorization endpoint. For more information on the differences between single and multi tenant registration, refer to [Microsoft's identity platform documentation](https://learn.microsoft.com/en-us/entra/identity-platform/howto-modify-supported-accounts).
191
+
192
+
{% endhint %}
193
+
194
+
{% hint style="warning" %}
195
+
196
+
The Client Secret value will expire and must be regenerated in the Entra admin center. Use configurable secret storage to provide the value to your code, rather than hard-coding it.
197
+
163
198
{% endhint %}
164
199
165
200
4. Add the Members authentication configuration in the `Program.cs` file:
0 commit comments