Base solution for your next web application
Open Closed

Multi-tenant with Email Login #1901


User avatar
0
poolpro created

Hello everyone,

I just started with the aspnetboilerplate project and downloaded my solution from the site. I am very impressed with the Multi-tenancy aspect but have a few questions. How would one make the login without tenant field with unique email login, I was looking through the code but seams the Abp class is pre-loaded as a DLL, I dont see the need for the Tenant field if unique Email is used to login then should be forwarded to tenant. and use domain name as tenant name. Is what i am proposing even possable through aspnetboilerplate? So if a user logs into the panel as <a href="mailto:[email protected]">[email protected]</a> he should be taken to his tenant, and if user is part of more than one tenant then the landing page after login should ask what tenant he/she would like to join at that login, with a drop-down list in his/her pages to switch from domain to domain. I'm sorry if what i am asking is not within the area or scope of aspnetboilerplate but i was just curious as i would like to make this a reality. Any thoughts or insights would be grateful.

Thanks


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Finding the tenancy name is related to applicaiton rather than the framework. You can change the template according to your needs.

    We didn't use email address's domain because in public SaaS apps, most people will use @gmail, @hotmail or similar email addresses, so we cannot identify their tenant from their email addresses.

    We can make email address unique but it's not easy in database per tenant architecture. If different tenants have different databases, we need to check all tenant databases for controlling email uniqueness.

    But as I said, you can play with the template according to your needs :).

  • User Avatar
    0
    poolpro created

    Thank you for your reply, And once again i must say i love the project. You are correct, Searching many databases for an email would not be feasible. I have come to the conclusion and have been working on trying to create a separate user database just for this purpose, this way the email would be unique to the login, and then redirected to the proper database for the users tenant, and if user is listed for multiple tenants he will get directed to his profile page that will list his or her tenant(s), from there they can choose what tenant they would like to login to. this will also have a tenanttoUser table which will allow for many to many relations from tenant to user and user to tenant and can have different roles for each tenant he or she is assigned (which would be great for a webmaster that that performs services for multiple sites). I have also decided that i will use an ACL type role management system so the owner of a tenant can assign user rights to individual items under a role or user as i have not decided which would be best at the moment, but user defining ACL i feel would stop from creating a role for a single user. Also i want the ACL to be dynamic by content, Menu items, modules, and administration, so think i will have to store the ACL as json so it can be written on a task as items are added. This will help me hide menu items if they are added to a role and that user does not have access to that role rather then block access to a page. I will update you as i get further with this project. and once again thank you for your feedback.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Thank you for sharing your idea in details. There is a UserAccount entity in module zero and it's stored in the host database. <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/09cb578f09ee0318b479aa31dd0ceff56a5d218d/src/Abp.Zero/Authorization/Users/UserAccount.cs">https://github.com/aspnetboilerplate/mo ... Account.cs</a>

    All the users in all databases (even if you use db per tenant) has a single record in this table. (AbpUserAccounts). And UserAccountSynchronizer class keeps this table up to date. <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/09cb578f09ee0318b479aa31dd0ceff56a5d218d/src/Abp.Zero/Authorization/Users/UserAccountSynchronizer.cs">https://github.com/aspnetboilerplate/mo ... ronizer.cs</a>

    Maybe you can extend this class according to your needs (add password and other fields to authanticate a user), and use this entity to authenticate users.

    We will be very happy to hear your progress.

  • User Avatar
    0
    ashgadala created

    same here happy to hear the progress on this poolpro