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
Write-Host-ForegroundColor Green "------------------------------------------------------------------------------------------------"
382
351
Write-Host"IMPORTANT: Please follow the instructions below to complete a few manual step(s) in the Azure portal":
383
352
Write-Host"- For client"
384
353
Write-Host" - Navigate to $clientPortalUrl"
385
354
Write-Host" - On Azure portal, create a security group named 'GroupAdmin' and assign some users to it. Afterwards, update the configuration files with the Object ID of the gruop you've just created."-ForegroundColor Red
386
-
Write-Host" - On Azure portal, create a security group named 'GroupMember' and assign some users to it. Afterwards, update the configuration files with the Object ID of the gruop you've just created."-ForegroundColor Red
387
-
Write-Host" - Security groups matching the names you provided have been created in this tenant (if not present already). On Azure portal, assign some users to it, and configure ID & Access tokens to emit Group IDs"-ForegroundColor Red
355
+
Write-Host" - On Azure portal, create a security group named 'GroupMember' and assign some users to it. Afterwards, update the configuration files with the Object ID of the gruop you've just created."-ForegroundColor Red
388
356
Write-Host-ForegroundColor Green "------------------------------------------------------------------------------------------------"
389
357
if($isOpenSSL-eq'Y')
390
358
{
@@ -416,7 +384,6 @@ try
416
384
}
417
385
catch
418
386
{
419
-
$_.Exception.ToString() |out-host
420
387
$message=$_
421
388
Write-Warning$Error[0]
422
389
Write-Host"Unable to register apps. Error is $message."-ForegroundColor White -BackgroundColor Red
"Comment": "On Azure portal, create a security group named 'GroupAdmin' and assign some users to it. Afterwards, update the configuration files with the Object ID of the gruop you've just created."
74
+
},
75
+
{
76
+
"Comment": "On Azure portal, create a security group named 'GroupMember' and assign some users to it. Afterwards, update the configuration files with the Object ID of the gruop you've just created."
77
+
}
63
78
]
64
-
}
65
-
],
66
-
"OptionalClaims": {
67
-
"IdTokenClaims": [
68
-
"acct"
69
-
]
70
-
},
71
-
"ManualSteps": [
72
-
{
73
-
"Comment": "On Azure portal, create a security group named 'GroupAdmin' and assign some users to it. Afterwards, update the configuration files with the Object ID of the gruop you've just created."
74
-
},
75
-
{
76
-
"Comment": "On Azure portal, create a security group named 'GroupMember' and assign some users to it. Afterwards, update the configuration files with the Object ID of the gruop you've just created."
name: Angular single-page application calling a protected AspNet Core web API and using Security Groups to implement Role-Based Access Control
21
-
description: Angular single-page application calling a protected AspNet web API and using Security Groups to implement Role-Based Access Control (RBAC)
15
+
name: Angular single-page application calling a protected ASP.NET Core web API using Security Groups to implement Role-Based Access Control
16
+
description: Angular single-page application calling a protected ASP.NET Core web API using Security Groups to implement Role-Based Access Control (RBAC)
22
17
---
23
18
24
-
# Angular single-page application calling a protected AspNet Core web API and using Security Groups to implement Role-Based Access Control
19
+
# Angular single-page application calling a protected ASP.NET Core web API using Security Groups to implement Role-Based Access Control
25
20
26
21
*[Overview](#overview)
27
22
*[Scenario](#scenario)
@@ -38,7 +33,7 @@ description: Angular single-page application calling a protected AspNet web API
38
33
39
34
This sample demonstrates a cross-platform application suite involving an Angular single-page application (*TodoListSPA*) calling an ASP.NET Core web API (*TodoListAPI*) secured with the Microsoft identity platform. In doing so, it implements **Role-based Access Control** (RBAC) by using Azure AD **Security Groups**.
40
35
41
-
Access control in Azure AD can also be done with, **App Roles** (see the [previous tutorial](../1-call-api-roles/README.md)) and/or **Delegated Permissions**. **Security Groups**, **App Roles** and **Delegated Permissions** in Azure AD are by no means mutually exclusive -they can be used in tandem to provide even finer grained access control.
36
+
Access control in Azure AD can also be done with, **App Roles** (see the [previous tutorial](../1-call-api-roles/README.md)) and/or **Delegated Permissions**. **Security Groups**, **App Roles** and **Delegated Permissions** in Azure AD are by no means mutually exclusive -they can be used in tandem to provide even finer grained access control.
42
37
43
38
In the sample, a dashboard component allows signed-in users to see the tasks assigned to them or other users based on their memberships to one of the two security groups, **GroupAdmin** and **GroupMember**.
44
39
@@ -176,7 +171,6 @@ To manually register the apps, as a first step you'll need to:
176
171
1. Select one of the available key durations (**6 months**, **12 months** or **Custom**) as per your security posture.
177
172
1. The generated key value will be displayed when you select the **Add** button. Copy and save the generated value for use in later steps.
178
173
1. You'll need this key later in your code's configuration files. This key value will not be displayed again, and is not retrievable by any other means, so make sure to note it from the Azure portal before navigating to any other screen or blade.
179
-
> :bulb: For enhanced security, instead of using client secrets, consider [using certificates](./README-use-certificate.md) and [Azure KeyVault](https://azure.microsoft.com/services/key-vault/#product-overview).
180
174
1. In the app's registration screen, select the **Expose an API** blade to the left to open the page where you can publish the permission as an API for which client applications can obtain [access tokens](https://aka.ms/access-tokens) for. The first thing that we need to do is to declare the unique [resource](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow) URI that the clients will be using to obtain access tokens for this API. To declare an resource URI(Application ID URI), follow the following steps:
181
175
1. Select **Set** next to the **Application ID URI** to generate a URI that is unique for this app.
182
176
1. For this sample, accept the proposed Application ID URI (`api://{clientId}`) by selecting **Save**. Read more about Application ID URI at [Validation differences by supported account types \(signInAudience\)](https://docs.microsoft.com/azure/active-directory/develop/supported-accounts-validation).
@@ -390,15 +384,17 @@ If a user is member of more groups than the overage limit (**150 for SAML tokens
390
384
391
385
#### Create the Overage scenario for testing
392
386
393
-
1. You can use the `BulkCreateGroups.ps1` provided in the [App Creation Scripts](./AppCreationScripts/) folder to create a large number of groups and assign users to them. This will help test overage scenarios during development. You'll need to enter a user Object ID when prompted by the `BulkCreateGroups.ps1` script.
387
+
1. You can use the [BulkCreateGroups.ps1](./AppCreationScripts/BulkCreateGroups.ps1) provided in the [App Creation Scripts](./AppCreationScripts/) folder to create a large number of groups and assign users to them. This will help test overage scenarios during development. You'll need to enter a user Object ID when prompted by the `BulkCreateGroups.ps1` script. If you would like to delete these groups, run the [BulkRemoveGroups.ps1](./AppCreationScripts/BulkRemoveGroups.ps1) after testing the overage scenario.
388
+
389
+
When overage occurs, the user's ID and/or access token will not gave the **groups** claim. Instead, a new claim named **_claim_names** will appear. This confirms that the overage scenario is reproduced.
394
390
395
391
When attending to overage scenarios, which requires a call to [Microsoft Graph](https://graph.microsoft.com) to read the signed-in user's group memberships, your app will need to have the [User.Read](https://docs.microsoft.com/graph/permissions-reference#user-permissions) and [GroupMember.Read.All](https://docs.microsoft.com/graph/permissions-reference#group-permissions) for the [getMemberGroups](https://docs.microsoft.com/graph/api/user-getmembergroups) API to execute successfully.
396
392
397
393
> :warning: For the overage scenario, make sure you have granted **Admin Consent** for the MS Graph API's **GroupMember.Read.All** scope (see the **App Registration** steps above).
398
394
399
395
##### Angular GroupGuard service
400
396
401
-
Consider the [group.guard.ts](./SPA/src/app/group.guard.ts). Here, we are checking whether the token for the user has the `_claim_names` claim, which indicates that the user has too many group memberships. If so, we redirect the user to the [overage](./SPA/src/app/overage/overage.component.ts) component. There, we initiate a call to MS Graph API's `https://graph.microsoft.com/v1.0/me/memberOf` endpoint to query the full list of groups that the user belongs to. Finally we check for the designated `groupID` among this list.
397
+
Consider the [group.guard.ts](./SPA/src/app/group.guard.ts). Here, we are checking whether the token for the user's ID token has the `_claim_names` claim, which indicates that the user has too many group memberships. If so, we redirect the user to the [overage](./SPA/src/app/overage/overage.component.ts) component. There, we initiate a call to MS Graph API's `https://graph.microsoft.com/v1.0/me/memberOf` endpoint to query the full list of groups that the user belongs to. Finally we check for the designated `groupID` among this list.
0 commit comments