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
1. Usesthe [MicrosoftGraphSDK](https://github.com/microsoftgraph/msgraph-sdk-dotnet) to carry out various operations with [Microsoft Graph](https://graph.microsoft.com).
203
204
1. Home\Index.cshtml
204
205
1. Thishassomecodetoprintthecurrentuser's claims
205
206
206
-
1. Startup.cs
207
-
208
207
1. Inthe `ConfigureServices` methodof `Startup.cs', add the following lines:
//This enables your application to use the Microsoft identity platform endpoint. This endpoint is capable of signing-in users both with their Work and School and Microsoft Personal accounts.
1. Inthe `ConfigureServices` methodof `Startup.cs', the following line instructs the asp.net security middleware to use the **roles** claim to fetch roles for authorization:
224
+
1. Inthe `ConfigureServices` methodof `Startup.cs', the following lines instruct the ASP.NET security middleware to use the **roles** claim to fetch roles for authorization:
237
225
238
226
```CSharp
239
-
// The claim in the Jwt token where App roles are available.
@@ -286,14 +287,14 @@ This project was created using the following command.
286
287
1. Add a reference from your newly generated project to `Microsoft.Identity.Web` (right click on the **Dependencies** node under your new project, and choose **Add Reference ...**, and then in the projects tab find the `Microsoft.Identity.Web` project)
287
288
1. Open the **Startup.cs** file and:
288
289
289
-
- in the `ConfigureServices` method, the following lines have been replaced :
290
+
- in the `ConfigureServices` method, the following lines:
//This enables your application to use the Microsoft identity platform endpoint. This endpoint is capable of signing-in users both with their Work and School and Microsoft Personal accounts.
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { Constants.ScopeUserRead })
@@ -302,7 +303,7 @@ This project was created using the following command.
302
303
services.AddGraphService(Configuration); // Adds the IMSGraphService as an available service for this app.
303
304
```
304
305
305
-
1. In the `ConfigureServices` method of `Startup.cs', add the following line:
306
+
1. In the `ConfigureServices` method of `Startup.cs', add the following lines:
306
307
307
308
```CSharp
308
309
// This is required to be instantiated before the OpenIdConnectOptions starts getting configured.
@@ -319,11 +320,15 @@ This project was created using the following command.
319
320
});
320
321
```
321
322
322
-
1. In the `ConfigureServices` method of `Startup.cs', the following line instructs the asp.net security middleware to use the **roles** claim to fetch roles for authorization:
323
+
1. In the `ConfigureServices` method of `Startup.cs', the following lines instruct the ASP.NET security middleware to use the **roles** claim to fetch roles for authorization.
323
324
324
325
```CSharp
325
-
// The claim in the Jwt token where App roles are available.
1. In the `HomeController.cs`, the following method is added with the `Authorize` attribute with the name of the policy that enforces that the signed-in user is present in the app role **UserReaders**, that permits listing of users in the tenant.
Copy file name to clipboardExpand all lines: 5-WebApp-AuthZ/5-2-Groups/README-incremental-instructions.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -218,7 +218,7 @@ The following files have the code that would be of interest to you:
218
218
1. Passes the **HttpContext.User** (the signed-in user) to the view.
219
219
1. UserProfileController.cs
220
220
1. Uses the **IMSGraphService** methods to fetch the signed-in user's group memberships.
221
-
1IMSGraphService.cs, MSGraphService.cs and UserGroupsAndDirectoryRoles.cs
221
+
1. IMSGraphService.cs, MSGraphService.cs and UserGroupsAndDirectoryRoles.cs
222
222
1. Uses the [Microsoft Graph SDK](https://github.com/microsoftgraph/msgraph-sdk-dotnet) to carry out various operations with [Microsoft Graph](https://graph.microsoft.com).
223
223
1. Home\Index.cshtml
224
224
1. This has some code to print the current user's claims
@@ -232,14 +232,14 @@ The following files have the code that would be of interest to you:
232
232
using Microsoft.Identity.Web;
233
233
```
234
234
235
-
- in the `ConfigureServices` method, the following lines have been replaced :
235
+
- in the `ConfigureServices` method, the following lines:
Copy file name to clipboardExpand all lines: 5-WebApp-AuthZ/5-2-Groups/README.md
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -232,8 +232,8 @@ The object id of the security groups the signed in user is member of is returned
232
232
233
233
### Support in ASP.NET Core middleware libraries
234
234
235
-
The asp.net middleware supports roles populated from claims by specifying the claim in the `RoleClaimType` property of `TokenValidationParameters`.
236
-
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.
235
+
The ASP.NET middleware supports roles populated from claims by specifying the claim in the `RoleClaimType` property of `TokenValidationParameters`.
236
+
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.
237
237
238
238
```CSharp
239
239
// Startup.cs
@@ -328,7 +328,7 @@ The following files have the code that would be of interest to you:
328
328
1. Passes the **HttpContext.User** (the signed-in user) to the view.
329
329
1. UserProfileController.cs
330
330
1. Uses the **IMSGraphService** methods to fetch the signed-in user's group memberships.
331
-
1IMSGraphService.cs, MSGraphService.cs and UserGroupsAndDirectoryRoles.cs
331
+
1. IMSGraphService.cs, MSGraphService.cs and UserGroupsAndDirectoryRoles.cs
332
332
1. Uses the [Microsoft Graph SDK](https://github.com/microsoftgraph/msgraph-sdk-dotnet) to carry out various operations with [Microsoft Graph](https://graph.microsoft.com).
333
333
1. Home\Index.cshtml
334
334
1. This has some code to print the current user's claims
@@ -342,16 +342,16 @@ The following files have the code that would be of interest to you:
342
342
using Microsoft.Identity.Web;
343
343
```
344
344
345
-
- in the `ConfigureServices` method, the following lines have been replaced :
345
+
- in the `ConfigureServices` method, the following lines:
// Uncomment the following lines code instruct the asp.net core middleware to use the data in the "groups" claim in the [Authorize] attribute and for User.IsInrole()
47
+
// See https://docs.microsoft.com/en-us/aspnet/core/security/authorization/roles for more info.
0 commit comments