apioo / fusio

Open source API management platform
https://www.fusio-project.org
Apache License 2.0
1.84k stars 218 forks source link

How to use multi tenancy? #569

Open yeyenpamula opened 1 month ago

yeyenpamula commented 1 month ago

@chriskapp How to use multi-tenancy? I've read the documentation and not found information about multi-tenancy.

chriskapp commented 1 month ago

@yeyenpamula there is indeed no documentation for this, I will try to add this with the next documentation update, but in general it is very easy, there is a APP_TENANT_ID environment variable which contains the identifier for each tenant, i.e. you could setup different sub-domains i.e. customer-a.acme.com and customer-b.acme.com and depending on the sub-domain you set the fitting APP_TENANT_ID.

Then in order for a user to use a tenant you need to setup the tenant s. https://www.fusio-project.org/api/backend#tag/tenant/operation/backend.tenant.setup and if not longer needed you can also remove the tenant https://www.fusio-project.org/api/backend#tag/tenant/operation/backend.tenant.remove

All you sub-domains can then be server from the same Fusio instance and database. You can also integrate the tenant id in your app by using i.e. the $context->getTenantId().

yeyenpamula commented 1 month ago

@chriskapp Thank you for answering. But I'm still confused.

Is there an example or easier explanation?

Should I install fusio on all my tenants?

chriskapp commented 1 month ago

@yeyenpamula unfortunately not, you would then need to wait for the documentation update.

Should I install fusio on all my tenants?

No, basically the tenant feature exist only so that you can install Fusio on a single server and serve multiple clients, which can be great to save costs. But the tenant feature is only useful, if you want to basically run a dedicated instance for each customer on a domain. Maybe you don`t need this if you simply build an app where your users register.