ASP.NET MVC Multiple Tenant Membership Provider

I am building a multi-tenant application with ASP.NET MVC and have a problem with user validation.

Situation

I have:

- table with user (identifier, name, name, email address) This table is designed so that users registered with two tenants no longer need to log in.

- table with Tentantuser (ID, TenantID, UserID (FK for table user), username, username, password, active) This table contains the password for logging in for one tenant.

Example:

  • UserX registered in TenantA and TenantB
  • UserX logs on to TenantA, with its username and password for TenantA
  • The system checks or the username and password are correct in the TenantUser table
  • The system checks UserX which user ID matches the identifier in the table. User
  • UserX is sent to TenantB and automatically registered

My problem:

How to create a custom provider so that I can verify the tenant's login and password? For instance:

public abstract bool ValidateUser(string username,string password); 

How can I tell my provider which tenant the user is on?

How can I change it like this:

  public overrides bool ValidateUser(string username,string password, string tenant); ? 

Or what other way to solve this problem?

+4
source share
1 answer

The application name parameter can be used to identify the tenant a / b, which can be specified in the configuration file. Then in your custom provider, you can use this to pull out the correct entry for the tenant. Do not go into customizing custom methods; that would be a pain.

NTN.

+4
source

Source: https://habr.com/ru/post/1310386/


All Articles