Skip to content

Commit 4e61346

Browse files
Merge branch 'shama/MultiTenant' of https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2 into shama/MultiTenant
2 parents 9570f74 + de50252 commit 4e61346

File tree

12 files changed

+35
-35
lines changed

12 files changed

+35
-35
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ Function ConfigureApplications
257257
Write-Host "'$($user.UserPrincipalName)' added as an application owner to app '$($serviceServicePrincipal.DisplayName)'"
258258
}
259259

260-
# rename the user_impersonation scope if it exists to match the readme steps or add a new scope
260+
# rename the access_as_user scope if it exists to match the readme steps or add a new scope
261261
$scopes = New-Object System.Collections.Generic.List[Microsoft.Open.AzureAD.Model.OAuth2Permission]
262262

263263
if ($scopes.Count -ge 0)
@@ -366,7 +366,7 @@ Function ConfigureApplications
366366

367367

368368
# Update config file for 'service'
369-
$configFile = $pwd.Path + "\..\TodoListService\appsettings.json"
369+
$configFile = $pwd.Path + "\..\ToDoListService\appsettings.json"
370370
Write-Host "Updating the sample code ($configFile)"
371371
$dictionary = @{ "Domain" = $tenantName;"TenantId" = 'common';"ClientId" = $serviceAadApplication.AppId;"ClientSecret" = $serviceAppKey };
372372
UpdateTextFile -configFilePath $configFile -dictionary $dictionary

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
{
5959
"App": "service",
6060
"SettingKind": "Text",
61-
"SettingFile": "\\..\\TodoListService\\appsettings.json",
61+
"SettingFile": "\\..\\ToDoListService\\appsettings.json",
6262
"Mappings": [
6363
{
6464
"key": "Domain",

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ description: "Protect a multi-tenant SaaS web application and a Web API which ca
4444

4545
## About this sample
4646

47-
This sample demonstrates how to protect a **multi-tenant** ASP.NET Core MVC web application (TodoListClient) which calls another **multi-tenant** ASP.NET Core Web API (TodoListService) with Microsoft Identity Platform. This sample builds on the concepts introduced in the [Build a multi-tenant SaaS web application that calls Microsoft Graph using Azure AD & OpenID Connect](../../../2-WebApp-graph-user\2-3-Multi-Tenant/README.md) sample. We advise you go through that sample once before trying this sample.
47+
This sample demonstrates how to protect a **multi-tenant** ASP.NET Core MVC web application (TodoListClient) which calls another **multi-tenant** ASP.NET Core Web API (ToDoListService) with Microsoft Identity Platform. This sample builds on the concepts introduced in the [Build a multi-tenant SaaS web application that calls Microsoft Graph using Azure AD & OpenID Connect](../../../2-WebApp-graph-user\2-3-Multi-Tenant/README.md) sample. We advise you go through that sample once before trying this sample.
4848

4949
### Scenario
5050

@@ -140,12 +140,12 @@ As a first step you'll need to:
140140
1. Sign in to the [Azure portal](https://portal.azure.com).
141141
1. If your account is present in more than one Azure AD tenant, select your profile at the top right corner in the menu on top of the page, and then **switch directory** to change your portal session to the desired Azure AD tenant..
142142

143-
#### Register the service app (WebApi-MultiTenant-TodoListService-v2)
143+
#### Register the service app (WebApi-MultiTenant-ToDoListService-v2)
144144

145145
1. Navigate to the Microsoft identity platform for developers [App registrations](https://go.microsoft.com/fwlink/?linkid=2083908) page.
146146
1. Select **New registration**.
147147
1. In the **Register an application page** that appears, enter your application's registration information:
148-
- In the **Name** section, enter a meaningful application name that will be displayed to users of the app, for example `WebApi-MultiTenant-TodoListService-v2`.
148+
- In the **Name** section, enter a meaningful application name that will be displayed to users of the app, for example `WebApi-MultiTenant-ToDoListService-v2`.
149149
- Under **Supported account types**, select **Accounts in any organizational directory**.
150150
- In the **Redirect URI (optional)** section, select **Web** in the combo-box and enter the following redirect URI: `https://localhost:44351/api/Home`.
151151
1. Select **Register** to create the application.
@@ -171,24 +171,24 @@ The first thing that we need to do is to declare the unique [resource](https://d
171171
- Select **Add a scope** button open the **Add a scope** screen and Enter the values as indicated below:
172172
- For **Scope name**, use `access_as_user`.
173173
- Select **Admins and users** options for **Who can consent?**
174-
- For **Admin consent display name** type `Access WebApi-MultiTenant-TodoListService-v2`
175-
- For **Admin consent description** type `Allows the app to access WebApi-MultiTenant-TodoListService-v2 as the signed-in user.`
176-
- For **User consent display name** type `Access WebApi-MultiTenant-TodoListService-v2`
177-
- For **User consent description** type `Allow the application to access WebApi-MultiTenant-TodoListService-v2 on your behalf.`
174+
- For **Admin consent display name** type `Access WebApi-MultiTenant-ToDoListService-v2`
175+
- For **Admin consent description** type `Allows the app to access WebApi-MultiTenant-ToDoListService-v2 as the signed-in user.`
176+
- For **User consent display name** type `Access WebApi-MultiTenant-ToDoListService-v2`
177+
- For **User consent description** type `Allow the application to access WebApi-MultiTenant-ToDoListService-v2 on your behalf.`
178178
- Keep **State** as **Enabled**
179179
- Click on the **Add scope** button on the bottom to save this scope.
180180

181-
#### Configure the service app (WebApi-MultiTenant-TodoListService-v2) to use your app registration
181+
#### Configure the service app (WebApi-MultiTenant-ToDoListService-v2) to use your app registration
182182

183183
Open the project in your IDE (like Visual Studio or Visual Studio Code) to configure the code.
184184

185185
>In the steps below, "ClientID" is the same as "Application ID" or "AppId".
186186
187-
1. Open the `TodoListService\appsettings.json` file
187+
1. Open the `ToDoListService\appsettings.json` file
188188
1. Find the app key `Domain` and replace the existing value with your Azure AD tenant name.
189189
1. Find the app key `TenantId` and replace the existing value with 'common'.
190-
1. Find the app key `ClientId` and replace the existing value with the application ID (clientId) of the `WebApi-MultiTenant-TodoListService-v2` application copied from the Azure portal.
191-
1. Find the app key `ClientSecret` and replace the existing value with the key you saved during the creation of the `WebApi-MultiTenant-TodoListService-v2` app, in the Azure portal.
190+
1. Find the app key `ClientId` and replace the existing value with the application ID (clientId) of the `WebApi-MultiTenant-ToDoListService-v2` application copied from the Azure portal.
191+
1. Find the app key `ClientSecret` and replace the existing value with the key you saved during the creation of the `WebApi-MultiTenant-ToDoListService-v2` app, in the Azure portal.
192192

193193
#### Register the client app (WebApp-MultiTenant-ToDoListClient-v2)
194194

@@ -216,8 +216,8 @@ Open the project in your IDE (like Visual Studio or Visual Studio Code) to confi
216216
1. In the app's registration screen, click on the **API permissions** blade in the left to open the page where we add access to the APIs that your application needs.
217217
- Click the **Add a permission** button and then,
218218
- Ensure that the **My APIs** tab is selected.
219-
- In the list of APIs, select the API `WebApi-MultiTenant-TodoListService-v2`.
220-
- In the **Delegated permissions** section, select the **Access 'WebApi-MultiTenant-TodoListService-v2'** in the list. Use the search box if necessary.
219+
- In the list of APIs, select the API `WebApi-MultiTenant-ToDoListService-v2`.
220+
- In the **Delegated permissions** section, select the **Access 'WebApi-MultiTenant-ToDoListService-v2'** in the list. Use the search box if necessary.
221221
- Click on the **Add permissions** button at the bottom.
222222

223223
#### Configure the client app (WebApp-MultiTenant-ToDoListClient-v2) to use your app registration
@@ -233,8 +233,8 @@ Open the project in your IDE (like Visual Studio or Visual Studio Code) to confi
233233
1. Find the app key `ClientSecret` and replace the existing value with the key you saved during the creation of the `WebApp-MultiTenant-ToDoListClient-v2` app, in the Azure portal.
234234
1. Find the app key `RedirectUri` and replace the existing value with the base address of the WebApp-MultiTenant-ToDoListClient-v2 project (by default `https://localhost:44321/`).
235235
1. Find the app key `TodoListScope` and replace the existing value with ScopeDefault.
236-
1. Find the app key `TodoListAppId` and replace the existing value with the application ID (clientId) of the `WebApi-MultiTenant-TodoListService-v2` application copied from the Azure portal.
237-
1. Find the app key `TodoListBaseAddress` and replace the existing value with the base address of the WebApi-MultiTenant-TodoListService-v2 project (by default `https://localhost:44351/`).
236+
1. Find the app key `TodoListAppId` and replace the existing value with the application ID (clientId) of the `WebApi-MultiTenant-ToDoListService-v2` application copied from the Azure portal.
237+
1. Find the app key `TodoListBaseAddress` and replace the existing value with the base address of the WebApi-MultiTenant-ToDoListService-v2 project (by default `https://localhost:44351/`).
238238
1. Find the app key `AdminConsentRedirectApi` and replace the existing value with "https://localhost:44351/api/Home".
239239

240240
### Step 3: Run the sample
@@ -257,7 +257,7 @@ This behavior is expected as the browser is not authenticated. The Web applicati
257257
##### Step 1. Install .NET Core dependencies
258258

259259
```console
260-
cd TodoListService
260+
cd ToDoListService
261261
dotnet restore
262262
```
263263

@@ -289,7 +289,7 @@ In both the console windows execute the below command:
289289

290290
Open your browser and navigate to `https://localhost:44321`.
291291

292-
> NOTE: Remember, the To-Do list is stored in memory in this `TodoListService` app. Each time you run the projects, your To-Do list will get emptied.
292+
> NOTE: Remember, the To-Do list is stored in memory in this `ToDoListService` app. Each time you run the projects, your To-Do list will get emptied.
293293
294294
### Testing the Application
295295

@@ -365,9 +365,9 @@ New-AzureADServicePrincipal -AppId -DisplayName
365365

366366
### Provisioning your Multi-tenant Apps in another Azure AD Tenant programatically
367367

368-
Often the user-based consent will be disabled in an Azure AD tenant or your application will be requesting permissions that requires a tenant-admin consent. In these scenarios, your application will need to utilize the `/adminconsent` endpoint to provision both the **ToDoListClient** and the **TodoListService** before the users from that tenant are able to sign-in to your app.
368+
Often the user-based consent will be disabled in an Azure AD tenant or your application will be requesting permissions that requires a tenant-admin consent. In these scenarios, your application will need to utilize the `/adminconsent` endpoint to provision both the **ToDoListClient** and the **ToDoListService** before the users from that tenant are able to sign-in to your app.
369369

370-
When provisioning, you have to take care of the dependency in the topology where the **ToDoListClient** is dependent on **TodoListService**. So in such a case, you would provision the **TodoListService** before the **ToDoListClient**.
370+
When provisioning, you have to take care of the dependency in the topology where the **ToDoListClient** is dependent on **ToDoListService**. So in such a case, you would provision the **ToDoListService** before the **ToDoListClient**.
371371

372372
### Code for the Web App (TodoListClient)
373373

@@ -466,7 +466,7 @@ public async Task<IActionResult> Create()
466466
}
467467
```
468468

469-
### Code for the Web API (TodoListService)
469+
### Code for the Web API (ToDoListService)
470470

471471
#### Admin consent Client Redirect
472472

4-WebApp-your-API/4-3-AnyOrg/TodoListService/Controllers/HomeController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Threading.Tasks;
55
using Microsoft.AspNetCore.Mvc;
66

7-
namespace TodoListService.Controllers
7+
namespace ToDoListService.Controllers
88
{
99
[Route("api/[controller]")]
1010
[Microsoft.AspNetCore.Authorization.AllowAnonymous]

4-WebApp-your-API/4-3-AnyOrg/TodoListService/Controllers/TodoListController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
using Microsoft.AspNetCore.Mvc;
77
using Microsoft.AspNetCore.Authorization;
88
using Microsoft.EntityFrameworkCore;
9-
using TodoListAPI.Models;
9+
using ToDoListService.Models;
1010
using Microsoft.Identity.Web.Resource;
1111
using Microsoft.Identity.Web;
1212
using Microsoft.Identity.Client;
1313
using System.Net.Http.Headers;
1414
using Microsoft.Graph;
1515
using System.Net;
1616

17-
namespace TodoListAPI.Controllers
17+
namespace ToDoListService.Controllers
1818
{
1919
[Authorize]
2020
[Route("api/[controller]")]

4-WebApp-your-API/4-3-AnyOrg/TodoListService/Models/TodoContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Microsoft.EntityFrameworkCore;
22

3-
namespace TodoListAPI.Models
3+
namespace ToDoListService.Models
44
{
55
public class TodoContext : DbContext
66
{

4-WebApp-your-API/4-3-AnyOrg/TodoListService/Models/TodoItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System.Collections.Generic;
55

6-
namespace TodoListAPI.Models
6+
namespace ToDoListService.Models
77
{
88
public class TodoItem
99
{

4-WebApp-your-API/4-3-AnyOrg/TodoListService/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Microsoft.AspNetCore.Hosting;
33
using Microsoft.Extensions.Hosting;
44

5-
namespace TodoListAPI
5+
namespace ToDoListService
66
{
77
public class Program
88
{

4-WebApp-your-API/4-3-AnyOrg/TodoListService/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"ASPNETCORE_ENVIRONMENT": "Development"
1818
}
1919
},
20-
"TodoListService": {
20+
"ToDoListService": {
2121
"commandName": "Project",
2222
"launchBrowser": true,
2323
"environmentVariables": {

4-WebApp-your-API/4-3-AnyOrg/TodoListService/Startup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
using Microsoft.Extensions.Configuration;
77
using Microsoft.Extensions.DependencyInjection;
88
using Microsoft.EntityFrameworkCore;
9-
using TodoListAPI.Models;
9+
using ToDoListService.Models;
1010
using Microsoft.AspNetCore.Authentication.JwtBearer;
1111
using System.Linq;
1212
using System;
1313

14-
namespace TodoListAPI
14+
namespace ToDoListService
1515
{
1616
public class Startup
1717
{

4-WebApp-your-API/4-3-AnyOrg/TodoListService/TodoListService.csproj renamed to 4-WebApp-your-API/4-3-AnyOrg/TodoListService/ToDoListService.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
5-
<UserSecretsId>aspnet-TodoListAPI-BA938C29-8BAB-4664-A688-8FD54049C1C3</UserSecretsId>
5+
<UserSecretsId>aspnet-ToDoListService-BA938C29-8BAB-4664-A688-8FD54049C1C3</UserSecretsId>
66
<WebProject_DirectoryAccessLevelKey>1</WebProject_DirectoryAccessLevelKey>
77
</PropertyGroup>
88

@@ -21,4 +21,4 @@
2121
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.3" Condition="'$(Configuration)' == 'Debug'" />
2222
</ItemGroup>
2323

24-
</Project>
24+
</Project>

4-WebApp-your-API/4-3-AnyOrg/WebApp-Calls-WebAPI-AnyOrg-v2.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.30011.22
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ToDoListClient", "ToDoListClient\ToDoListClient.csproj", "{76DD6C86-2323-4F29-A6EB-FF336144EBFA}"
77
EndProject
8-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TodoListService", "TodoListService\TodoListService.csproj", "{F6AA7AF4-A64C-42B6-BDE4-3E1A49FE4207}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ToDoListService", "TodoListService\ToDoListService.csproj", "{F6AA7AF4-A64C-42B6-BDE4-3E1A49FE4207}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution

0 commit comments

Comments
 (0)