Skip to content

Commit 4f9474e

Browse files
committed
Removed MSA manual step and Readme Update as per MIW 2.0
1 parent 6230626 commit 4f9474e

File tree

3 files changed

+21
-41
lines changed

3 files changed

+21
-41
lines changed

4-WebApp-your-API/4-3-AnyOrg/AppCreationScripts/Configure.ps1

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,8 @@ Function ConfigureApplications
379379
Write-Host ""
380380
Write-Host -ForegroundColor Green "------------------------------------------------------------------------------------------------"
381381
Write-Host "IMPORTANT: Please follow the instructions below to complete a few manual step(s) in the Azure portal":
382-
Write-Host "- For 'service'"
383-
Write-Host " - Navigate to '$servicePortalUrl'"
384-
Write-Host " - Navigate to the Manifest page and change 'signInAudience' to 'AzureADandPersonalMicrosoftAccount'." -ForegroundColor Red
385-
Write-Host " - Navigate to the Manifest page and change 'accessTokenAcceptedVersion' to 2." -ForegroundColor Red
386382
Write-Host "- For 'client'"
387383
Write-Host " - Navigate to '$clientPortalUrl'"
388-
Write-Host " - Navigate to the Manifest page and change 'signInAudience' to 'AzureADandPersonalMicrosoftAccount'." -ForegroundColor Red
389-
Write-Host " - Navigate to the Manifest page and change 'accessTokenAcceptedVersion' to 2." -ForegroundColor Red
390384
Write-Host " - [Optional] If you are a tenant admin, you can navigate to the API Permisions page and select 'Grant admin consent for (your tenant)'" -ForegroundColor Red
391385

392386
Write-Host -ForegroundColor Green "------------------------------------------------------------------------------------------------"

4-WebApp-your-API/4-3-AnyOrg/AppCreationScripts/sample.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@
2424
"Resource": "Microsoft Graph",
2525
"DelegatedPermissions": [ "User.Read.All" ]
2626
}
27-
],
28-
"ManualSteps": [
29-
{
30-
"Comment": "Navigate to the Manifest page and change 'signInAudience' to 'AzureADandPersonalMicrosoftAccount'."
31-
},
32-
{
33-
"Comment": "Navigate to the Manifest page and change 'accessTokenAcceptedVersion' to 2."
34-
}
3527
]
3628
},
3729
{
@@ -50,12 +42,6 @@
5042
}
5143
],
5244
"ManualSteps": [
53-
{
54-
"Comment": "Navigate to the Manifest page and change 'signInAudience' to 'AzureADandPersonalMicrosoftAccount'."
55-
},
56-
{
57-
"Comment": "Navigate to the Manifest page and change 'accessTokenAcceptedVersion' to 2."
58-
},
5945
{
6046
"Comment": "[Optional] If you are a tenant admin, you can navigate to the API Permisions page and select 'Grant admin consent for (your tenant)'"
6147
}

4-WebApp-your-API/4-3-AnyOrg/Readme.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ This sample demonstrates how to develop a multi-tenant ASP.NET Core MVC web appl
4242

4343
### Scenario
4444

45-
In this sample, we would protect an ASP.Net Core Web API using the Microsoft Identity Platform. The Web API will be protected using Azure Active Directory OAuth Bearer Authorization. The API will support authenticated users with Work and School accounts. Further on the API will also call a downstream API (Microsoft Graph) on-behalf of the signed-in user to provide additional value to its client apps.
45+
In this sample, we would protect an ASP.Net Core Web API using the Microsoft Identity Platform. The Web API will be protected using Azure Active Directory OAuth 2.0 Bearer Authorization. The API will support authenticated users with Work and School accounts. Further on the API will also call a downstream API (Microsoft Graph) on-behalf of the signed-in user to provide additional value to its client apps.
4646

4747
### Overview
4848

@@ -348,10 +348,9 @@ When provisioning, you have to take care of the dependency in the topology where
348348

349349
In `Startup.cs`, below lines of code enables Microsoft identity platform endpoint. This endpoint is capable of signing-in users both with their Work and School and Microsoft Personal accounts.
350350
```csharp
351-
services.AddSignIn(Configuration).
352-
AddWebAppCallsProtectedWebApi(Configuration, new string[]
353-
{Configuration["TodoList:TodoListScope"] }.
354-
AddInMemoryTokenCaches();
351+
services.AddMicrosoftWebAppAuthentication(Configuration)
352+
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { Configuration["TodoList:TodoListScope"] })
353+
.AddInMemoryTokenCaches();
355354
```
356355

357356
The following code injects the ToDoList service implementation in the client
@@ -473,22 +472,23 @@ By marking your application as multi-tenant, your application will be able to si
473472

474473
```csharp
475474
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
476-
.AddProtectedWebApi(options =>
477-
{
478-
Configuration.Bind("AzureAd", options);
479-
options.Events = new JwtBearerEvents();
480-
options.Events.OnTokenValidated = async context =>
481-
{
482-
string[] allowedTenants = { /* list of tenant IDs */ };
483-
string tenantId = context.Principal.Claims.FirstOrDefault(x => x.Type == "tid"
484-
|| x.Type == "http://schemas.microsoft.com/identity/claims/tenantid")?.Value;
485-
if (!allowedTenants.Contains(tenantId))
486-
{
487-
throw new Exception("This tenant is not authorized");
488-
}
489-
};
490-
},
491-
options => { Configuration.Bind("AzureAd", options); });
475+
.AddMicrosoftWebApi(options =>
476+
{
477+
Configuration.Bind("AzureAd", options);
478+
options.Events = new JwtBearerEvents();
479+
options.Events.OnTokenValidated = async context =>
480+
{
481+
string[] allowedTenants = {/* list of tenant IDs */ };
482+
string tenantId = context.Principal.Claims.FirstOrDefault(x => x.Type == "tid" || x.Type == "http://schemas.microsoft.com/identity/claims/tenantid")?.Value;
483+
484+
if (!allowedTenants.Contains(tenantId))
485+
{
486+
throw new Exception("This tenant is not authorized");
487+
}
488+
};
489+
}, options => { Configuration.Bind("AzureAd", options); })
490+
.AddMicrosoftWebApiCallsWebApi(Configuration)
491+
.AddInMemoryTokenCaches();
492492
```
493493

494494

0 commit comments

Comments
 (0)