Skip to content

Commit e557aed

Browse files
merged
2 parents 3f4ff4c + 1a87639 commit e557aed

File tree

5 files changed

+33
-21
lines changed

5 files changed

+33
-21
lines changed

5-AccessControl/2-call-api-groups/AppCreationScripts/BulkCreateGroups.ps1

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ Function ConfigureApplications {
7171

7272
Write-Host "Connecting to Microsoft Graph"
7373
if ($tenantId -eq "") {
74-
Connect-MgGraph -Scopes "Group.ReadWrite.All GroupMember.ReadWrite.All" -Environment $azureEnvironmentName
74+
Connect-MgGraph -Scopes "User.Read Group.ReadWrite.All GroupMember.ReadWrite.All" -Environment $azureEnvironmentName
7575
$tenantId = (Get-MgContext).TenantId
7676
}
7777
else {
78-
Connect-MgGraph -TenantId $tenantId -Scopes "Group.ReadWrite.All GroupMember.ReadWrite.All" -Environment $azureEnvironmentName
78+
Connect-MgGraph -TenantId $tenantId -Scopes "User.Read Group.ReadWrite.All GroupMember.ReadWrite.All" -Environment $azureEnvironmentName
7979
}
8080

8181
# Add user object Id here
@@ -86,14 +86,21 @@ Function ConfigureApplications {
8686
CreateGroupsAndAssignUser -user $user
8787
}
8888

89+
if ($null -eq (Get-Module -ListAvailable -Name "Microsoft.Graph.Authentication")) {
90+
Install-Module "Microsoft.Graph.Authentication" -Scope CurrentUser
91+
Write-Host "Installed Microsoft.Graph.Authentication module. If you are having issues, please create a new PowerShell session and try again."
92+
}
93+
8994
if ($null -eq (Get-Module -ListAvailable -Name "Microsoft.Graph.Groups")) {
90-
Install-Module "Microsoft.Graph.Groups" -Scope CurrentUser
95+
Install-Module "Microsoft.Graph.Groups" -Scope CurrentUser
96+
Write-Host "Installed Microsoft.Graph.Groups module. If you are having issues, please create a new PowerShell session and try again."
9197
}
9298

9399
Import-Module Microsoft.Graph.Groups
94100

95101
if ($null -eq (Get-Module -ListAvailable -Name "Microsoft.Graph.Users")) {
96-
Install-Module "Microsoft.Graph.Users" -Scope CurrentUser
102+
Install-Module "Microsoft.Graph.Users" -Scope CurrentUser
103+
Write-Host "Installed Microsoft.Graph.Users module. If you are having issues, please create a new PowerShell session and try again."
97104
}
98105

99106
Import-Module Microsoft.Graph.Users

5-AccessControl/2-call-api-groups/AppCreationScripts/BulkRemoveGroups.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ Function ConfigureApplications {
7272

7373
$ErrorActionPreference = "Stop"
7474

75+
if ($null -eq (Get-Module -ListAvailable -Name "Microsoft.Graph.Authentication")) {
76+
Install-Module "Microsoft.Graph.Authentication" -Scope CurrentUser
77+
Write-Host "Installed Microsoft.Graph.Authentication module. If you are having issues, please create a new PowerShell session and try again."
78+
}
79+
7580
if ($null -eq (Get-Module -ListAvailable -Name "Microsoft.Graph.Groups")) {
7681
Install-Module "Microsoft.Graph.Groups" -Scope CurrentUser
7782
}

5-AccessControl/2-call-api-groups/AppCreationScripts/Configure.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ Function UpdateTextFile([string] $configFilePath, [System.Collections.HashTable]
327327
Write-Host "IMPORTANT: Please follow the instructions below to complete a few manual step(s) in the Azure portal":
328328
Write-Host "- For client"
329329
Write-Host " - Navigate to $clientPortalUrl"
330-
Write-Host " - On Azure portal, create a group named GroupAdmin and assign some users to it, then configure your ID and Access token to emit GroupID in your app registration." -ForegroundColor Red
331-
Write-Host " - On Azure portal, create a group named GroupMember and assign some users to it, then configure your ID and Access token to emit GroupID in your app registration." -ForegroundColor Red
330+
Write-Host " - On Azure portal, create a security group named GroupAdmin and assign some users to it, then configure your ID and Access token to emit GroupID in your app registration." -ForegroundColor Red
331+
Write-Host " - On Azure portal, create a security group named GroupMember and assign some users to it, then configure your ID and Access token to emit GroupID in your app registration." -ForegroundColor Red
332332
Write-Host -ForegroundColor Green "------------------------------------------------------------------------------------------------"
333333
if($isOpenSSL -eq 'Y')
334334
{

5-AccessControl/2-call-api-groups/AppCreationScripts/sample.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@
5959
},
6060
"ManualSteps": [
6161
{
62-
"Comment": "On Azure portal, create a group named 'GroupAdmin' and assign some users to it, then configure your ID and Access token to emit GroupID in your app registration."
62+
"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."
6363
},
6464
{
65-
"Comment": "On Azure portal, create a group named 'GroupMember' and assign some users to it, then configure your ID and Access token to emit GroupID in your app registration."
65+
"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."
6666
}
6767
]
6868
}

5-AccessControl/2-call-api-groups/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ Open the project in your IDE (like Visual Studio or Visual Studio Code) to confi
228228
1. Find the key `Enter_the_Tenant_Info_Here` and replace the existing value with your Azure AD tenant/directory ID.
229229
1. Find the key `Enter_the_Web_Api_Application_Id_Here` and replace the existing value with the application ID (clientId) of `msal-angular-app` app copied from the Azure portal.
230230
231-
### Create Security Groups
231+
#### Create Security Groups
232232
233233
> :warning: You may already have security groups with the names below defined in your tenant and/or you may not have permissions to create new security groups. In that case, skip the steps below and update the configuration files in your project(s) with the desired names/IDs of the groups.
234234
@@ -249,7 +249,7 @@ Open the project in your IDE (like Visual Studio or Visual Studio Code) to confi
249249
250250
For more information, visit: [Create a basic group and add members using Azure AD](https://docs.microsoft.com/azure/active-directory/fundamentals/active-directory-groups-create-azure-portal)
251251
252-
### Configure Security Groups
252+
#### Configure Security Groups
253253
254254
You have two different options available to you on how you can further configure your application to receive the `groups` claim.
255255
@@ -258,22 +258,22 @@ You have two different options available to you on how you can further configure
258258
259259
> To get the on-premise group's `samAccountName` or `On Premises Group Security Identifier` instead of Group ID, please refer to the document [Configure group claims for applications with Azure Active Directory](https://docs.microsoft.com/azure/active-directory/hybrid/how-to-connect-fed-group-claims#prerequisites-for-using-group-attributes-synchronized-from-active-directory).
260260
261-
#### Configure your application to receive **all the groups** the signed-in user is assigned to, including nested groups
261+
##### Configure your application to receive **all the groups** the signed-in user is assigned to, including nested groups
262262
263263
1. In the app's registration screen, select the **Token Configuration** blade in the left to open the page where you can configure the claims provided tokens issued to your application.
264264
1. Select the **Add groups claim** button on top to open the **Edit Groups Claim** screen.
265265
1. Select `Security groups` **or** the `All groups (includes distribution lists but not groups assigned to the application)` option. Choosing both negates the effect of `Security Groups` option.
266266
1. Under the **ID** section, select `Group ID`. This will result in Azure AD sending the [object id](https://docs.microsoft.com/graph/api/resources/group?view=graph-rest-1.0) of the groups the user is assigned to in the **groups** claim of the [ID Token](https://docs.microsoft.com/azure/active-directory/develop/id-tokens) that your app receives after signing-in a user.
267267
268-
#### Configure your application to receive the `groups` claim values from a **filtered set of groups** a user may be assigned to
268+
##### Configure your application to receive the `groups` claim values from a **filtered set of groups** a user may be assigned to
269269
270-
##### Prerequisites, benefits and limitations of using this option
270+
###### Prerequisites, benefits and limitations of using this option
271271
272272
1. This option is useful when your application is interested in a selected set of groups that a signing-in user may be assigned to and not every security group this user is assigned to in the tenant. This option also saves your application from running into the [overage](#groups-overage-claim) issue.
273273
1. This feature is not available in the [Azure AD Free edition](https://azure.microsoft.com/pricing/details/active-directory/).
274274
1. **Nested group assignments** are not available when this option is utilized.
275275
276-
##### Steps to enable this option in your app
276+
###### Steps to enable this option in your app
277277
278278
1. In the app's registration screen, select the **Token Configuration** blade in the left to open the page where you can configure the claims provided tokens issued to your application.
279279
1. Select the **Add groups claim** button on top to open the **Edit Groups Claim** screen.
@@ -295,17 +295,17 @@ You have two different options available to you on how you can further configure
295295
>
296296
> When you set **User assignment required?** to **Yes**, Azure AD will check that only users assigned to your application in the **Users and groups** blade are able to sign-in to your app. You can assign users directly or by assigning security groups they belong to.
297297
298-
### Configure the app to recognize Group IDs
298+
#### Configure the app to recognize Group IDs
299299
300300
> :warning: During **Token Configuration**, if you have chosen any other option except **groupID** (e.g. like **DNSDomain\sAMAccountName**) you should enter the **group name** (for example `contoso.com\Test Group`) instead of the **object ID** below:
301301
302-
1. Open the `SPA\src\app\app-config.ts` file.
303-
1. Find the app key `groups.groupAdmin` and replace the existing value with the **object ID** of the **GroupAdmin** group copied from the Azure portal.
304-
1. Find the app key `groups.groupMember` and replace the existing value with the **object ID** of the **GroupMember** group copied from the Azure portal.
302+
1. Open the `SPA\src\app\auth-config.ts` file.
303+
1. Find the key `Enter the objectID for GroupAdmin group copied from Azure Portal` and replace the existing value with the **object ID** of the **GroupAdmin** group copied from the Azure portal.
304+
1. Find the key `Enter the objectID for GroupMember group copied from Azure Portal` and replace the existing value with the **object ID** of the **GroupMember** group copied from the Azure portal.
305305
306306
1. Open the `API\TodoListAPI\appsettings.json` file.
307-
2. Find the app key `Groups.GroupAdmin` and replace the existing value with the **object ID** of the **GroupAdmin** group copied from the Azure portal.
308-
3. Find the app key `Groups.GroupMember` and replace the existing value with the **object ID** of the **GroupMember** group copied from the Azure portal.
307+
2. Find the key `Enter the objectID for GroupAdmin group copied from Azure Portal` and replace the existing value with the **object ID** of the **GroupAdmin** group copied from the Azure portal.
308+
3. Find the key `Enter the objectID for GroupMember group copied from Azure Portal` and replace the existing value with the **object ID** of the **GroupMember** group copied from the Azure portal.
309309
310310
### Step 6: Running the sample
311311
@@ -377,7 +377,7 @@ If a user is member of more groups than the overage limit (**150 for SAML tokens
377377
378378
#### Create the Overage scenario for testing
379379

380-
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. Remember to change the user's **objectId** provided in the `BulkCreateGroups.ps1` script.
380+
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.
381381

382382
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.
383383

0 commit comments

Comments
 (0)