Skip to content

Commit 15dad59

Browse files
committed
Merge branch 'shama/MultiTenant' of https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2 into shama/MultiTenant
2 parents 1046522 + ebfee98 commit 15dad59

File tree

3 files changed

+133
-83
lines changed

3 files changed

+133
-83
lines changed

2-WebApp-graph-user/2-3-Multi-Tenant/README.md

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,36 @@ products:
1515
- dotnet
1616
- CSharp
1717
- office-ms-graph
18-
description: "Build a multi-tenant SaaS web application that calls Microsoft Graph using Azure AD & OpenID Connect"
18+
description: "Protect a multi-tenant SaaS web application that calls Microsoft Graph using Azure AD & OpenID Connect"
1919
---
2020

21-
# Build a multi-tenant SaaS web application that calls Microsoft Graph using Azure AD & OpenID Connect
21+
# Protect a multi-tenant SaaS web application that calls Microsoft Graph using Azure AD & OpenID Connect
2222

2323
> This sample is for Azure AD, not Azure AD B2C.
2424
2525
[![Build status](https://identitydivision.visualstudio.com/IDDP/_apis/build/status/AAD%20Samples/.NET%20client%20samples/ASP.NET%20Core%20Web%20App%20tutorial)](https://identitydivision.visualstudio.com/IDDP/_build/latest?definitionId=819)
2626

27+
- [About this sample](#about-this-sample)
28+
- [Overview](#overview)
29+
- [Scenario](#scenario)
30+
- [How to run this sample](#how-to-run-this-sample)
31+
- [Step 1: Clone or download this repository](#step-1-clone-or-download-this-repository)
32+
- [Step 2: Register the sample application with your Azure Active Directory tenant](#step-2-register-the-sample-application-with-your-azure-active-directory-tenant)
33+
- [Step 3: Configure the sample to use your Azure AD tenant](#step-3-configure-the-sample-to-use-your-azure-ad-tenant)
34+
- [Step 4: Run the sample](#step-4-run-the-sample)
35+
- [About The code](#about-the-code)
36+
- [Usage of `/common` endpoint](#usage-of-common-endpoint)
37+
- [Service principal provisioning for new tenants (onboarding process)](#service-principal-provisioning-for-new-tenants-onboarding-process)
38+
- [Custom token validation allowing only registered tenants](#custom-token-validation-allowing-only-registered-tenants)
39+
- [Partitioning data by tenant](#partitioning-data-by-tenant)
40+
- [Acquiring Access token for Microsoft Graph for each tenant](#acquiring-access-token-for-microsoft-graph-for-each-tenant)
41+
- [Troubleshooting](#troubleshooting)
42+
- [Error AADSTS650051](#error-aadsts650051)
43+
- [Error `The provided request must include a 'response_type' input parameter`](#error-the-provided-request-must-include-a-response_type-input-parameter)
44+
- [Next Steps](#next-steps)
45+
- [Contributing](#contributing)
46+
- [Learn more](#learn-more)
47+
2748
## About this sample
2849

2950
This sample shows how to build an ASP.NET Core MVC web application that uses OpenID Connect to sign in users from multiple Azure AD tenants. Additionally it also introduces developers to the concept of a [multi-tenant](https://docs.microsoft.com/azure/active-directory/develop/single-and-multi-tenant-apps) Azure Active Directory application.
@@ -205,7 +226,7 @@ This sample is using the OpenID Connect ASP.NET Core middleware to sign in users
205226

206227
You can trigger the middleware to send an OpenID Connect sign-in request by decorating a class or method with the `[Authorize]` attribute or by issuing a challenge (see the [AccountController.cs](https://github.com/aspnet/AspNetCore/blob/master/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Controllers/AccountController.cs) file which is part of ASP.NET Core):
207228

208-
These steps are encapsulated in the [Microsoft.Identity.Web](..\..\Microsoft.Identity.Web) project, and in particular in the [WebAppServiceCollectionExtensions.cs](..\..\Microsoft.Identity.Web\WebAppServiceCollectionExtensions.cs) file
229+
These steps are encapsulated in the [Microsoft.Identity.Web](https://github.com/AzureAD/microsoft-identity-web) project, and in particular in the [WebAppServiceCollectionExtensions.cs](https://github.com/AzureAD/microsoft-identity-web/blob/master/src/Microsoft.Identity.Web/WebAppExtensions/WebAppServiceCollectionExtensions.cs) file
209230

210231
### Usage of `/common` endpoint
211232

@@ -287,7 +308,7 @@ services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationSch
287308
});
288309
```
289310

290-
### Data partitioning by tenant
311+
### Partitioning data by tenant
291312

292313
There are two common scenarios regarding data partition on a multi-tenant app. Having a separate database for each tenant or having a single database and using the **tenantId** to separate the data of each tenant. In this sample, we have taken the single database approach to save the ToDo items for all users from all tenants.
293314

@@ -331,6 +352,10 @@ If you had provisioned a service principal of this app in the past and created a
331352
If you try to sign-in with a Microsoft account (MSA), such as hotmail.com, outlook.com, and msn.com, you'd receive this error during admin consent because MSA is not supported at the `/common` endpoint which this sample is using to obtain the admin consent.
332353
Please use an admin account with from the Azure AD tenant for this purpose.
333354

355+
## Next Steps
356+
357+
If your application topology comprises of multiple apps, for example a web API that the multi-tenant app will call, we recommend you also go through the [Protect a multi-tenant SaaS web application and a Web API which calls Microsoft Graph on-behalf of the user with the Microsoft Identity Platform](../../4-WebApp-your-API\4-3-AnyOrg/Readme.md) sample.
358+
334359
## Contributing
335360

336361
If you'd like to contribute to this sample, see [CONTRIBUTING.MD](/CONTRIBUTING.md).
@@ -341,23 +366,24 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
341366

342367
To learn more about single and multi-tenant apps
343368

344-
- [Tenancy in Azure Active Directory](https://docs.microsoft.com/en-us/azure/active-directory/develop/single-and-multi-tenant-apps)
345-
- [How to: Sign in any Azure Active Directory user using the multi-tenant application pattern](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-convert-app-to-be-multi-tenant)
346-
- [Application and service principal objects in Azure Active Directory](https://docs.microsoft.com/en-us/azure/active-directory/develop/app-objects-and-service-principals)
347-
- [National Clouds](https://docs.microsoft.com/en-us/azure/active-directory/develop/authentication-national-cloud)
348-
- [Endpoints](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols#endpoints)
369+
- [Tenancy in Azure Active Directory](https://docs.microsoft.com/azure/active-directory/develop/single-and-multi-tenant-apps)
370+
- [How to: Sign in any Azure Active Directory user using the multi-tenant application pattern](https://docs.microsoft.com/azure/active-directory/develop/howto-convert-app-to-be-multi-tenant)
371+
- [Application and service principal objects in Azure Active Directory](https://docs.microsoft.com/azure/active-directory/develop/app-objects-and-service-principals)
372+
- [National Clouds](https://docs.microsoft.com/azure/active-directory/develop/authentication-national-cloud)
373+
- [Endpoints](https://docs.microsoft.com/azure/active-directory/develop/active-directory-v2-protocols#endpoints)
349374
- [Multi-tenant SaaS database tenancy patterns](https://docs.microsoft.com/azure/sql-database/saas-tenancy-app-design-patterns)
350375

351376
To learn more about admin consent experiences
352-
- [Understanding Azure AD application consent experiences](https://docs.microsoft.com/en-us/azure/active-directory/develop/application-consent-experience)
353-
- [Understand user and admin consent](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-convert-app-to-be-multi-tenant#understand-user-and-admin-consent)
377+
378+
- [Understanding Azure AD application consent experiences](https://docs.microsoft.com/azure/active-directory/develop/application-consent-experience)
379+
- [Understand user and admin consent](https://docs.microsoft.com/azure/active-directory/develop/howto-convert-app-to-be-multi-tenant#understand-user-and-admin-consent)
354380

355381
To learn more about token validation, see
382+
356383
- [Validating tokens](https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/wiki/ValidatingTokens)
357-
- [Validating an id_token](https://docs.microsoft.com/en-us/azure/active-directory/develop/id-tokens#validating-an-id_token)
384+
- [Validating an id_token](https://docs.microsoft.com/azure/active-directory/develop/id-tokens#validating-an-id_token)
358385

359386
To understand more about app registration, see:
360387

361388
- [Quickstart: Register an application with the Microsoft identity platform (Preview)](https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app)
362-
- [Quickstart: Configure a client application to access web APIs (Preview)](https://docs.microsoft.com/azure/active-directory/develop/quickstart-configure-app-access-web-apis)
363-
389+
- [Quickstart: Configure a client application to access web APIs (Preview)](https://docs.microsoft.com/azure/active-directory/develop/quickstart-configure-app-access-web-apis)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Sample": {
3-
"Title": "Sign a user into a Web application using Microsoft Identity Platform and call a protected ASP.NET Core Web API, which calls Microsoft Graph on-behalf of the user",
3+
"Title": "Protect a multi-tenant SaaS web application and a Web API which calls Microsoft Graph on-behalf of the user with the Microsoft Identity Platform",
44
"Level": 400,
55
"Client": "ASP.NET Core Web App",
66
"Service": "ASP.NET Core Web API",
@@ -43,7 +43,7 @@
4343
],
4444
"ManualSteps": [
4545
{
46-
"Comment": "[Optional] If you are a tenant admin, you can navigate to the API Permisions page and select 'Grant admin consent for (your tenant)'"
46+
"Comment": "[Optional] If you are a tenant admin, you can navigate to the API Permissions page and select 'Grant admin consent for (your tenant)'"
4747
}
4848
]
4949
}

0 commit comments

Comments
 (0)