kaffy
kaffy copied to clipboard
Adds multitenancy support
Why:
-
When building an admin dashboard is not always true that:
- There is only one repo
- The repo is not dynamic
This change addresses the need by:
- Adding a resource level repo config that can be set when creating the resources list, to allow for multiple repos. It defaults to the ecto repo config in the env.
- Adding a new configurable function called
set_dynamic_repo
, which takes the connection as based on that it will set the dynamic repo. Since the dynamic repo is set per process, this is done on every controller action, so that we can ensure it is set properly. An example of this could be by setting a cookie with the tenant, which a plug can assign to the connection and have theset_dynamic_repo
use that to decide what to do. - Adding a new form of extension called navigation extras, which allows adding html to the top navigation. This can be used by, for example, having a select with the multiple tenants
This changes quite a few things and I don't expect you to agree with all the decisions, but it should allow us to get the conversation going at least. I'm not super familiar with kaffy's codebase, but I tried to leverage as much of the existing API as possible and ensure that no existing configuration need to change.
Tries to solve #179.
Hey @zamith Thank you for this super effort! This feature would put Kaffy in a great advantage and make it usable for even more projects. I'll need a couple of days to check and test the changes and I'll get back to you.
Great to hear that you're interested. I have this working on a project already and can try to provide some examples of how the integration looks like if you need it, even though the project is private.
hi @zamith I know it has been a while since you opened this PR. I am wondering would you be able to share examples of integration for the multi tenant application?
Some background: I opened a new question here https://github.com/aesmail/kaffy/issues/251 that might be related to this PR. The use case I have is a B2B startup where each team will have access to data within that organization and I also need to let team members create different environments such as Dev, Test etc.
Hi,
Would you be so kind as to do this again to the master branch?
Thanks, Gavin.