Hello to the Strapi team and the Community ,
With our team, we’ve been taking a look at Strapi to compare with our current CMS and we were looking into using Strapi as a multi-tenant.
We provide a mobile application to multiple companies, each one of them has their own private data to administrate and store in the DB.
In Strapi we can create Role
s for each of these companies and restrict the data they can access using RBAC, so no big problem on the administration side.
Now for limiting access to the data from the API it gets a bit more difficult.
Each company will have one and only one User/Token
that will be used the access the Strapi back-end when making API calls.
By default calling the route of a content-type
will return all the data of that content-type
, meaning we will get the data of all companies on an API call, and of course we don’t want that.
We can filter the data with a policy, and by adding a tenant_id
relational field
linked to User
to our content-type
s, we can now check that the id
of the User
making the api call is the same as the content-type
's tenant_id
to filter the data, meaning a tenant can now only call the content linked to it’s User
's id
, great!
The problem now is for adding the tenant_id
when an Admin User
creates content, we need the field
to be autocompleted with the id
of the User
that will make the API request.
How can we make it so that when an Admin User
of Role
“Company X” add content, the tenant_id
field
will be autocompleted with the id
of the User
corresponding to “Company X” ?