Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit b80897c

Browse files
merged
2 parents 64aa3a2 + 311f837 commit b80897c

File tree

3 files changed

+13
-52
lines changed

3 files changed

+13
-52
lines changed

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

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,6 @@ if ($null -eq (Get-Module -ListAvailable -Name "Microsoft.Graph.Groups")) {
1313

1414
Import-Module Microsoft.Graph.Groups
1515

16-
<#.Description
17-
This function creates a new Azure AD Security Group with provided values
18-
#>
19-
Function CreateSecurityGroup([string] $name, [string] $description)
20-
{
21-
Write-Host "Creating a security group by the name '$name'."
22-
$newGroup = New-MgGroup -Description $description -DisplayName $name -MailEnabled:$false -SecurityEnabled:$true -MailNickName $name
23-
return Get-MgGroup -Filter "DisplayName eq '$name'"
24-
}
25-
26-
<#.Description
27-
This function first checks and then creates a new Azure AD Security Group with provided values, if required
28-
#>
29-
Function CreateIfNotExistsSecurityGroup([string] $name, [string] $description, [switch] $promptBeforeCreate)
30-
{
31-
32-
# check if Group exists
33-
$group = Get-MgGroup -Filter "DisplayName eq '$name'"
34-
35-
if( $group -eq $null)
36-
{
37-
if ($promptBeforeCreate)
38-
{
39-
$confirmation = Read-Host "Proceed to create a new security group named '$name' in the tenant ? (Y/N)"
40-
41-
if($confirmation -eq 'y')
42-
{
43-
$group = CreateSecurityGroup -name $name -description $description
44-
}
45-
}
46-
else
47-
{
48-
Write-Host "No Security Group created!"
49-
}
50-
}
51-
52-
return $group
53-
}
54-
5516
<#.Description
5617
This function first checks and then deletes an existing Azure AD Security Group, if required
5718
#>

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,9 @@ Function ConfigureApplications
347347

348348
# rename the user_impersonation scope if it exists to match the readme steps or add a new scope
349349

350-
# delete default scope i.e. User_impersonation
351-
# Alex: the scope deletion doesn't work - see open issue - https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/1054
350+
# delete default scope i.e. user_impersonation
352351
$scopes = New-Object System.Collections.Generic.List[Microsoft.Graph.PowerShell.Models.MicrosoftGraphPermissionScope]
353-
$scope = $clientAadApplication.Api.Oauth2PermissionScopes | Where-Object { $_.Value -eq "User_impersonation" }
352+
$scope = $clientAadApplication.Api.Oauth2PermissionScopes | Where-Object { $_.Value -eq "user_impersonation" }
354353

355354
if($scope -ne $null)
356355
{
@@ -412,12 +411,11 @@ Function ConfigureApplications
412411

413412
# Create any security groups that this app requires.
414413

415-
$newGroup = CreateIfNotExistsSecurityGroup -name 'GroupAdmin' -description 'Admin Security Group' -promptBeforeCreate 'Y'
414+
$GroupAdmin = CreateIfNotExistsSecurityGroup -name 'GroupAdmin' -description 'Admin Security Group' -promptBeforeCreate 'Y'
416415
Write-Host "group id of 'GroupAdmin'" -> $newGroup.Id -ForegroundColor Green
417416

418-
$newGroup = CreateIfNotExistsSecurityGroup -name 'GroupMember' -description 'User Security Group' -promptBeforeCreate 'Y'
419-
Write-Host "group id of 'GroupMember'" -> $newGroup.Id -ForegroundColor Green
420-
Write-Host "Don't forget to assign the users you wish to work with to the newly created security groups !" -ForegroundColor Red
417+
$GroupMember = CreateIfNotExistsSecurityGroup -name 'GroupMember' -description 'User Security Group' -promptBeforeCreate 'Y'
418+
Write-Host "group id of 'GroupMember'" -> $newGroup.Id -ForegroundColor Green
421419

422420
# print the registered app portal URL for any further navigation
423421
Write-Host "Successfully registered and configured that app registration for 'msal-angular-app' at `n $clientPortalUrl" -ForegroundColor Red
@@ -438,7 +436,7 @@ Function ConfigureApplications
438436
# $configFile = $pwd.Path + "\..\SPA\src\app\auth-config.ts"
439437
$configFile = $(Resolve-Path ($pwd.Path + "\..\SPA\src\app\auth-config.ts"))
440438

441-
$dictionary = @{ "Enter_the_Application_Id_Here" = $clientAadApplication.AppId;"Enter_the_Tenant_Info_Here" = $tenantId;"Enter_the_Web_Api_Application_Id_Here" = $clientAadApplication.AppId;"Enter the object ID for GroupAdmin group copied from Azure Portal" = $GroupAdmin.objectId;"Enter the object ID for GroupMember group copied from Azure Portal" = $GroupMember.objectId };
439+
$dictionary = @{ "Enter_the_Application_Id_Here" = $clientAadApplication.AppId;"Enter_the_Tenant_Info_Here" = $tenantId;"Enter_the_Web_Api_Application_Id_Here" = $clientAadApplication.AppId;"Enter the object ID for GroupAdmin group copied from Azure Portal" = $GroupAdmin.Id;"Enter the object ID for GroupMember group copied from Azure Portal" = $GroupMember.Id };
442440

443441
Write-Host "Updating the sample config '$configFile' with the following config values:" -ForegroundColor Green
444442
$dictionary

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ To manually register the apps, as a first step you'll need to:
177177
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.
178178
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.
179179
> :bulb: For enhanced security, instead of using client secrets, consider [using certificates](https://github.com/AzureAD/microsoft-identity-web/wiki/Certificates) and [Azure KeyVault](https://azure.microsoft.com/services/key-vault/#product-overview).
180-
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:
180+
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:
181181
1. Select **Set** next to the **Application ID URI** to generate a URI that is unique for this app.
182182
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).
183183
@@ -206,16 +206,18 @@ To manually register the apps, as a first step you'll need to:
206206
1. Select the **Add a permission** button and then:
207207
1. Ensure that the **My APIs** tab is selected.
208208
1. In the list of APIs, select the API `msal-angular-app`.
209-
* Since this app signs-in users, we will now proceed to select **delegated permissions**, which is is requested by apps when signing-in users.
210-
1. In the **Delegated permissions** section, select **access_via_group_assignments** in the list. Use the search box if necessary.
209+
1. Select **delegated permissions**, which is is requested by apps when signing-in users.
210+
1. In the **Delegated permissions** section, select **access_via_group_assignments** in the list. Use the search box if necessary.
211211
1. Select the **Add permissions** button at the bottom.
212212
1. Select the **Add a permission** button and then:
213213
1. Ensure that the **Microsoft APIs** tab is selected.
214214
1. In the *Commonly used Microsoft APIs* section, select **Microsoft Graph**
215-
* Since this app signs-in users, we will now proceed to select **delegated permissions**, which is is requested by apps when signing-in users.
216-
1. In the **Delegated permissions** section, select **User.Read**, **GroupMember.Read.All** in the list. Use the search box if necessary.
215+
1. Select **delegated permissions**, which is is requested by apps when signing-in users.
216+
1. In the **Delegated permissions** section, select **User.Read**, **GroupMember.Read.All** in the list. Use the search box if necessary.
217217
1. Select the **Add permissions** button at the bottom.
218218
219+
> :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).
220+
219221
##### Configure Optional Claims
220222
221223
1. Still on the same app registration, select the **Token configuration** blade to the left.

0 commit comments

Comments
 (0)