Chatwoot: Setup subdomains for accounts, provide data isolation

Created on 22 Nov 2019  路  5Comments  路  Source: chatwoot/chatwoot

We should be providing data isolation to each account, contact/conversations should not be linked across the orgs. With the existing setup, only change we would require is to add subdomain for each account, rest of the data isolation is in place already.

  • [ ] Setup subdomain for each account

Most helpful comment

@mukesh4139 apartment doesn't officially support rails 6 at the moment: https://github.com/influitive/apartment/issues/617

The gem provided data isolation via creating separate schemas/databases. The solution we are looking for here doesn't require to go that deep. All the data models in the codebase have an account id attribute, So it's relatively easy to isolate records belonging to that particular account.

Also, we should be conscious about introducing new gems into the repository, as we try to keep the project up to date with the latest rails version. adding new gems will require us to depend on them to update and support the latest versions.


This change, in essence, is after signing up on the hosted version of chatwoot, the user should be using the app via subdomain.chatwoot.com instead of app.chatwoot.com.

The changes we are looking for here [ not an exhaustive list ]

  • have an attribute in an account that stores the subdomain name [ ensure uniqueness ]
  • users can set up a subdomain on signup flow along with the organization name
  • make changes in app/docs so that we can support xyc.localhost.com / xyc.chatwoot.com based on the environment
  • when a request comes in from a subdomain map the current_account to account with that subdomain.

Apart from that, there are chances of roadblocks arising while developing this, we need to figure them out as they come by.


Once again thanks a lot for the interest to contribute to chatwoot. This issue is a relatively lower priority since we are focusing on the community edition more for the next couple of months instead of the hosted one.

If you are looking to work on something just for this weekend, I can help you find a higher priority item. If you still like to continue on this one, I will be glad to help as well. Let me know if you have any questions.

All 5 comments

We can use the Apartment Gem and provide subdomain isolation.
https://github.com/influitive/apartment

Any other suggestions are welcome.

@pranavrajs
Can you assign this to me, I can work on this on the upcoming weekend.

@mukesh4139 apartment doesn't officially support rails 6 at the moment: https://github.com/influitive/apartment/issues/617

The gem provided data isolation via creating separate schemas/databases. The solution we are looking for here doesn't require to go that deep. All the data models in the codebase have an account id attribute, So it's relatively easy to isolate records belonging to that particular account.

Also, we should be conscious about introducing new gems into the repository, as we try to keep the project up to date with the latest rails version. adding new gems will require us to depend on them to update and support the latest versions.


This change, in essence, is after signing up on the hosted version of chatwoot, the user should be using the app via subdomain.chatwoot.com instead of app.chatwoot.com.

The changes we are looking for here [ not an exhaustive list ]

  • have an attribute in an account that stores the subdomain name [ ensure uniqueness ]
  • users can set up a subdomain on signup flow along with the organization name
  • make changes in app/docs so that we can support xyc.localhost.com / xyc.chatwoot.com based on the environment
  • when a request comes in from a subdomain map the current_account to account with that subdomain.

Apart from that, there are chances of roadblocks arising while developing this, we need to figure them out as they come by.


Once again thanks a lot for the interest to contribute to chatwoot. This issue is a relatively lower priority since we are focusing on the community edition more for the next couple of months instead of the hosted one.

If you are looking to work on something just for this weekend, I can help you find a higher priority item. If you still like to continue on this one, I will be glad to help as well. Let me know if you have any questions.

@sojan-official Please let me know the higher priority item.

@mukesh4139 do you think https://github.com/chatwoot/chatwoot/issues/348 is a good fit?

closing this since we will be doing an alternative approach to this with: https://github.com/chatwoot/chatwoot/issues/402

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pranavrajs picture pranavrajs  路  4Comments

MaheshCasiraghi picture MaheshCasiraghi  路  5Comments

tabrza picture tabrza  路  3Comments

petebytes picture petebytes  路  3Comments

niklaskorz picture niklaskorz  路  3Comments