fullstackhero / dotnet-starter-kit

Production Grade Cloud-Ready .NET 8 Starter Kit (Web API + Blazor Client) with Multitenancy Support, and Clean/Modular Architecture that saves roughly 200+ Development Hours! All Batteries Included.
https://fullstackhero.net/dotnet-webapi-boilerplate/
MIT License
5.22k stars 1.56k forks source link

Support for many to many tenant-user relationship #482

Closed akema-trebla closed 2 years ago

akema-trebla commented 2 years ago

Is your feature request related to a problem? Please describe. Currently it appears each user can belong to only one tenant.

Describe the solution you'd like A user should be able to exist in and switch between multiple tenants.

Describe alternatives you've considered Since the tenant Table and Users table may be in different databases, could we have a table that stores the email addresses of users in a particular tenant in the root database and manage the email addresses when there are changes in the user table. Also doing the reverse on the User table by having a list of supported tenants?

What do you think?

Additional context During login a user should be able to select from a list of tenants they belong to (if they are in more than one tenant or acquire the tenantId if they belong to only one tenant) based on the email address provided.

fretje commented 2 years ago

See discussions about this https://github.com/fullstackhero/dotnet-webapi-boilerplate/discussions/335 and https://github.com/fullstackhero/dotnet-webapi-boilerplate/discussions/248 and https://github.com/fullstackhero/dotnet-webapi-boilerplate/issues/408

I think people are mixing up multi-tenancy with multi-location or multi-division or whatever you wanna call it...

Multitenancy means the application code is shared between different tenants... not the data.

Even wikipedia explicitly mentions "user management" as "dedicated":

With a multitenant architecture, a software application is designed to provide every tenant a dedicated share of the instance - including its data, configuration, user management, tenant individual functionality and non-functional properties.

akema-trebla commented 2 years ago

Thanks for the insights @fretje.

I think what I had in mind is similar to what you suggested in #335

That is keeping the tenants as is but having a list of identifiers for the various "businesses" that are supported. I may not have articulated it well.

Based on the number of discussions that have gone on concerning this, would it be a terrible idea for us to consider implementing in this template?

kallievz commented 2 years ago

I may be wrong, but looking at the schema/logic, it could be in theory possible to update the tenantid on the Identity User Instance to achieve the above mentioned.

We are working on a project that where we maintain and do support on multiple tenants with one-many clients. Simplicity would just mean updating the entityid on user, re-apply roles/permission based on new entity, auto-logout and reaaply for new token to get new claims.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

akema-trebla commented 2 years ago

Sorry for the late response. Been a bit swamped.

What do you think about this?

@fretje @iammukeshm