Skip to content

Enhancing multi tenant sample #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Nov 27, 2019
Merged

Enhancing multi tenant sample #206

merged 33 commits into from
Nov 27, 2019

Conversation

TiagoBrenck
Copy link
Contributor

Purpose

A multi-tenant app goes beyond setting organizations as tenant. There are more topics that are essential for a developer to know when developing a simple multi-tenant app.

With help @kalyankrishna1 's help, we enhanced the multi-tenant sample to cover the topics:

  • /common endpoint
  • Service principle provision on other tenants
  • Data Partition
  • Graph token issued by signed user's tenant

This new sample is not a level 100 anymore, since it brings more complex topics. In order to provide a better experience, it uses a SQL DB, but there is the option of running it using in memory DB (thanks to EntityFramework).

Does this introduce a breaking change?

[ ] Yes
[x] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Get the code

  • Test the code
    The DB will be created automatically. If you want to run it using InMemory DB, read the line 48 on Startup.cs

Ideally you will want to have 2 tenants to test it.

What to Check

Verify that the following are valid

  • You can onboard different tenants and sign-in users (common endpoint and SP provisioning)
  • You can CRUD todo items but cannot see items from other tenants (Data partition)
  • When editing your todo item, a list of active users from your tenant is shown (Graph AT by tenant)

Other Information

⚠️ If you had created this sample in the past already: Delete its enterprise app from the other tenants before re-creating this application.

@jennyf19
Copy link
Contributor

jennyf19 commented Nov 19, 2019

using Microsoft.AspNetCore;

do you need license info for samples? #Resolved


Refers to: 2-WebApp-graph-user/2-3-Multi-Tenant/Program.cs:1 in ca3aa52. [](commit_id = ca3aa52, deletion_comment = False)

Copy link
Contributor

@jmprieur jmprieur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good @TiagoBrenck
however, I was not able to have the sample work after running the app creation scripts when going through the emboarding process. I got the following:

AADSTS50011: The reply url specified in the request does not match the reply urls configured for the application: 'f4378b43-1d37-404f-82c1-704914b95f18'.

It's not registering https://localhost:44321/Onboarding/ProcessCode as a redirect URI

I wonder if we don't want to plan an enhancement to use the Graph SDK (instead of hand crafting classes for the Graph response). What do you think @kalyankrishna1 ?

In the other samples we use the reduced license header, not the full one.

"PasswordCredentials": "Auto",
"RequiredResourcesAccess": [
{
"Resource": "Microsoft Graph",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The chapter 1 is about signing-in to a web app? not calling graph?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmprieur are you sure you have the latest version? I reverted this change already.

## About this sample

This sample shows how to build an ASP.NET Core MVC web application that usesOpenID 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.

Copy link
Contributor

@jmprieur jmprieur Nov 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to mention why it calls the graph? and also that it calls ARM?

@TiagoBrenck
Copy link
Contributor Author

TiagoBrenck commented Nov 19, 2019

@jmprieur I am using the Graph SDK. It is on MSGraphService.cs

@jmprieur
Copy link
Contributor

my bad, @TiagoBrenck

@jmprieur jmprieur self-requested a review November 20, 2019 14:28
Copy link
Contributor

@jmprieur jmprieur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
I tested an it works great
the only thing I'd change is the UserSecretsId> value in the csproj because this project is so different from the others that we'd want it to be unique

Keeping the same value for this one could impact negatively users who do several chapters (It did impact me and it took me a while to figure out that it was picking-up secrets and client ID of the other chapters)

@TiagoBrenck
Copy link
Contributor Author

Ok @jmprieur I will change. Me and Kalyan also discussed a better flow for the onboarding on the navigation menu, so I will update it as well

Copy link
Contributor

@jmprieur jmprieur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @TiagoBrenck

Copy link
Contributor

@kalyankrishna1 kalyankrishna1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with reviews.

@TiagoBrenck TiagoBrenck merged commit 62fbab4 into master Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants