Open Closed

Multi tenant with a centralized IdentityServer #1822


User avatar
0
BernardoTeixeira created
  • ABP Framework version: v3.1.1 / 4.4.0
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes

I'm trying to use the multi tentant. But I have some problems with this. I want to have one Identity Server and multiple APIs. Login to the Identity Server and then have the multi tenant/ConnectionString, so I can make requests to a different API using the correct connectionString.

Is Abp supporting this example? And if yes, how can I do it? Everytime I try to add a multi tentant to a user I can't make the login.


15 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The default hierarchical project and microservice project support functions. You can manage the connection string of the tenant.

    Everytime I try to add a multi tentant to a user I can't make the login.

    Can you share your current practices?

  • User Avatar
    0
    BernardoTeixeira created

    Hi,

    I'm trying to associate a tenant with a user. So that I can login with this user and every request I make to the api, the api will connect to the correct database. But I cannot associate a tenant with a user.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    I'm trying to associate a tenant with a user

    hi

    Such a design is currently not supported.

  • User Avatar
    0
    BernardoTeixeira created

    hi,

    so the user to login need to know the username, password and tenant name, right?

    How can I have 1 identityserver with one DB, and then have 1 API(sales for example) using multiple databases for each tenant?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    so the user to login need to know the username, password and tenant name, right?

    Yes, Usually we need to know the current tenant.

    How can I have 1 identityserver with one DB, and then have 1 API(sales for example) using multiple databases for each tenant?

    identityserver should also support multi-tenancy. Just like the default template.

  • User Avatar
    0
    BernardoTeixeira created

    hi,

    Im using ODataController, how can I get the tenant without using the abpController?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    https://docs.abp.io/en/abp/latest/Multi-Tenancy#determining-the-current-tenant

  • User Avatar
    0
    BernardoTeixeira created

    Hi,

    the currentTentant is null

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi Bernardo, can you remove the $ sign and try again? Because when you define it with $ sign it converts string (because of string interpolation) as "0.somedomain.com" instead of "{0}.somedomain.com".

    {0} is the placeholder to determine current tenant's unique name. => https://docs.abp.io/en/abp/4.4/Multi-Tenancy#domain-subdomain-tenant-resolver

  • User Avatar
    0
    BernardoTeixeira created

    Hi Bernardo, can you remove the $ sign and try again? Because when you define it with $ sign it converts string (because of string interpolation) as "0.somedomain.com" instead of "{0}.somedomain.com".

    {0} is the placeholder to determine current tenant's unique name. => https://docs.abp.io/en/abp/4.4/Multi-Tenancy#domain-subdomain-tenant-resolver

    I got the same result, currentTenant null

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Can you add the DomainTenantResolveContributor to TenantResolvers and try again?

    DomainTenantResolveContributor: Tries to resolve tenancy name from an url, generally from a domain or subdomain.

    Configure<AbpTenantResolveOptions>(options =>
    {
        options.AddDomainTenantResolver("{0}.somedomain.com");
                    
        options.TenantResolvers.Add(new DomainTenantResolveContributor()); //add DomainTenantResolveContributor
        //...
    });
    
  • User Avatar
    0
    BernardoTeixeira created

    this is what I have

    The problem Im having, in the API A I lost the tenant of the user. Probably because I'm using ODataController and not AbpController So I can't make selects in the DB with that tentantId. I just want to know the tenant, so I can get the right data for that tenant. I would like to get the tenant by the cookie because I have the tenant there or some request I could make to IdentityServer.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi BernardoTeixeira

    Can you share some request infos of API A?

    Tenant can be included in HTTP request

    https://docs.abp.io/en/abp/latest/Multi-Tenancy#determining-the-current-tenant

    Are you using the OpenID Connect in API A?

  • User Avatar
    0
    BernardoTeixeira created

    Instead of using cookies or headers. Can I use subdomains, and with that the user don't need to know the tenant name when he is login.

    This can be done? If yes, how?

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Can I use subdomains

    https://docs.abp.io/en/abp/4.4/Multi-Tenancy#domain-subdomain-tenant-resolver https://github.com/abpframework/abp-samples/tree/master/DomainTenantResolver

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09