Skip to content

Commit 6d6c16f

Browse files
committed
Changes related to permission update from Directory.Read.All to GroupMember.Read.All
1 parent 3a193fc commit 6d6c16f

File tree

6 files changed

+42
-58
lines changed

6 files changed

+42
-58
lines changed

5-WebApp-AuthZ/5-2-Groups/AppCreationScripts/Configure.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ Function ConfigureApplications
206206
-IdentifierUris "https://$tenantName/WebApp-GroupClaims" `
207207
-PasswordCredentials $key `
208208
-GroupMembershipClaims "SecurityGroup" `
209-
-Oauth2AllowImplicitFlow $true `
210209
-PublicClient $False
211210

212211
# create the service principal of the newly created application
@@ -234,7 +233,7 @@ Function ConfigureApplications
234233
# Add Required Resources Access (from 'webApp' to 'Microsoft Graph')
235234
Write-Host "Getting access from 'webApp' to 'Microsoft Graph'"
236235
$requiredPermissions = GetRequiredPermissions -applicationDisplayName "Microsoft Graph" `
237-
-requiredDelegatedPermissions "Directory.Read.All" `
236+
-requiredDelegatedPermissions "GroupMember.Read.All" `
238237

239238
$requiredResourcesAccess.Add($requiredPermissions)
240239

5-WebApp-AuthZ/5-2-Groups/AppCreationScripts/sample.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"RequiredResourcesAccess": [
2626
{
2727
"Resource": "Microsoft Graph",
28-
"DelegatedPermissions": [ "Directory.Read.All" ]
28+
"DelegatedPermissions": [ "GroupMember.Read.All" ]
2929
}
3030
]
3131
}

5-WebApp-AuthZ/5-2-Groups/Infrastructure/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace WebApp_OpenIDConnect_DotNet.Infrastructure
33
public static class Constants
44
{
55
public const string ScopeUserRead = "User.Read";
6-
public const string ScopeDirectoryReadAll = "Directory.Read.All";
6+
public const string ScopeDirectoryReadAll = "GroupMember.Read.All";
77

88
public const string BearerAuthorizationScheme = "Bearer";
99
}

5-WebApp-AuthZ/5-2-Groups/README-incremental-instructions.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ page_type: sample
1010
languages:
1111
- csharp
1212
products:
13-
- azure
13+
- microsoft-authentication-library
14+
- microsoft-identity-platform
1415
- azure-active-directory
1516
- dotnet
16-
- office-ms-graph
17+
- microsoft-graph-api
1718
description: "Add authorization using groups & group claims to an ASP.NET Core Web app that signs-in users with the Microsoft identity platform"
1819
---
1920

@@ -42,17 +43,13 @@ This sample first leverages the ASP.NET Core OpenID Connect middleware to sign i
4243
4344
To run this sample, you'll need:
4445

45-
- [Visual Studio 2019](https://aka.ms/vsdownload) or just the [.NET Core SDK](https://www.microsoft.com/net/learn/get-started)
46-
- An Internet connection
47-
- A Windows machine (necessary if you want to run the app on Windows)
48-
- An OS X machine (necessary if you want to run the app on Mac)
49-
- A Linux machine (necessary if you want to run the app on Linux)
46+
- [Visual Studio](https://visualstudio.microsoft.com/downloads/)
5047
- An Azure Active Directory (Azure AD) tenant. For more information on how to get an Azure AD tenant, see [How to get an Azure AD tenant](https://azure.microsoft.com/documentation/articles/active-directory-howto-tenant/)
51-
- A user account in your Azure AD tenant. This sample will not work with a Microsoft account (formerly Windows Live account). Therefore, if you signed in to the [Azure portal](https://portal.azure.com) with a Microsoft account and have never created a user account in your directory before, you need to do that now.
48+
- A user account in your Azure AD tenant. This sample will not work with a **personal Microsoft account**. Therefore, if you signed in to the [Azure portal](https://portal.azure.com) with a personal account and have never created a user account in your directory before, you need to do that now.
5249

5350
> Please make sure to have one or more user accounts in the tenant assigned to a few security groups in your tenant. Please follow the instructions in [Create a basic group and add members using Azure Active Directory](https://docs.microsoft.com/azure/active-directory/fundamentals/active-directory-groups-create-azure-portal) to create a few groups and assign users to them if not already done.
5451
55-
### Step 1: Clone or download this repository
52+
### Step 1: In the downloaded folder
5653

5754
From your shell or command line:
5855

@@ -113,8 +110,8 @@ Now you have two different options available to you on how you can further confi
113110

114111
1. Clean and rebuild the solution, and run it.
115112

116-
1. Open your web browser and make a request to the app. The app immediately attempts to authenticate you to the Microsoft identity platform. Sign in with a *work or school account* from the tenant where you created this app.
117-
1. On the home page, the app lists the various claims it obtained from your ID token. You'd notice one more claims named `groups`.
113+
1. Open your web browser and make a request to the app. The app immediately attempts to authenticate you to the Microsoft identity platform. You can sign-in with a *work or school account* from the tenant where you created this app. But sign-in with admin for the first time as admin consent is required for `GroupMember.Read.All` permission.
114+
1. On the home page, the app lists the various claims it obtained from your ID token. You'd notice one more claims named `groups`.
118115
1. On the top menu, click on the signed-in user's name **[email protected]**, you should now see all kind of information about yourself including their picture. Beneath that, a list of all the security groups that the signed-in user is assigned to are listed as well. All of this was obtained by making calls to Microsoft Graph. This list is useful if the **Overage** scenario occurs with this signed-in user. The [overage](#groups-overage-claim) scenario is discussed later in this article.
119116

120117
> Did the sample not work for you as expected? Did you encounter issues trying this sample? Then please reach out to us using the [GitHub Issues](../../../../issues) page.
@@ -137,8 +134,8 @@ The object id of the security groups the signed in user is member of is returned
137134

138135
### Support in ASP.NET Core middleware libraries
139136

140-
The asp.net middleware supports roles populated from claims by specifying the claim in the `RoleClaimType` property of `TokenValidationParameters`.
141-
Since the `groups` claim contains the object ids of the security groups than actual names by default, you'd use the group id's instead of group names. See [Role-based authorization in ASP.NET Core](https://docs.microsoft.com/aspnet/core/security/authorization/roles) for more info.
137+
The ASP.NET middleware supports roles populated from claims by specifying the claim in the `RoleClaimType` property of `TokenValidationParameters`.
138+
Since the `groups` claim contains the object IDs of the security groups than actual names by default, you'd use the group ID's instead of group names. See [Role-based authorization in ASP.NET Core](https://docs.microsoft.com/aspnet/core/security/authorization/roles) for more info.
142139

143140
```CSharp
144141
// Startup.cs
@@ -243,7 +240,7 @@ The following files have the code that would be of interest to you:
243240

244241
```CSharp
245242
services.AddMicrosoftWebAppAuthentication(Configuration)
246-
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { "User.Read", "Directory.Read.All" })
243+
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { "User.Read", "GroupMember.Read.All" })
247244
.AddInMemoryTokenCaches();
248245

249246
services.AddMSGraphService(Configuration); // Adds the IMSGraphService as an available service for this app.
@@ -252,7 +249,6 @@ The following files have the code that would be of interest to you:
252249
1. if you used the Powershell scripts provided in the [AppCreationScripts](.\AppCreationScripts) folder, then note the extra parameter `-GroupMembershipClaims` in the `Configure.ps1` script.
253250

254251
```PowerShell
255-
-Oauth2AllowImplicitFlow $true `
256252
-GroupMembershipClaims "SecurityGroup" `
257253
-PublicClient $False
258254
```
@@ -261,7 +257,7 @@ The following files have the code that would be of interest to you:
261257

262258
Use [Stack Overflow](http://stackoverflow.com/questions/tagged/msal) to get support from the community.
263259
Ask your questions on Stack Overflow first and browse existing issues to see if someone has asked your question before.
264-
Make sure that your questions or comments are tagged with [ `msal` `azure-active-directory`].
260+
Make sure that your questions or comments are tagged with [ `msal` `azure-active-directory` `dotnet`].
265261

266262
If you find a bug in the sample, please raise the issue on [GitHub Issues](../../../../issues).
267263

@@ -273,7 +269,7 @@ To provide a recommendation, visit the following [User Voice page](https://feedb
273269

274270
## Learn more
275271

276-
- Learn how [Microsoft.Identity.Web](../../Microsoft.Identity.Web) works, in particular hooks-up to the ASP.NET Core ODIC events
272+
- Learn how [Microsoft.Identity.Web](https://aka.ms/idweblib) works, in particular hooks-up to the ASP.NET Core ODIC events
277273

278274
- To understand more about groups roles and the various claims in tokens, see:
279275
- [Configure group claims for applications with Azure Active Directory (Public Preview)](https://docs.microsoft.com/azure/active-directory/hybrid/how-to-connect-fed-group-claims#configure-the-azure-ad-application-registration-for-group-attributes)

0 commit comments

Comments
 (0)