Back

multi tenancy / teams resources isolation

  • 0
  • General
oferardi
15 May, 2023, 16:50

Hi

I need to develop a multi tennat app with isolation. Each customer system shall send information to the db using the api.

My first idea was that Each customer will be a team.

  1. According to the documenting I shall use api key and not jwt token. But in this method there is security risk as the data will be exposed to all customers (teams). Using jwt with the admin user of a team (if possible) has rate limits which creates another problem.

Is there a solution for currently or any plan to solve this issue?

Is it a way to automatically provision a docker for each customer with pre configured db, functions etc.

What is the right way to solve it?

Thank you

TL;DR
The user is seeking support for implementing multi-tenancy and resource isolation in their application. They are concerned about the security of customer data and want to ensure that each customer's data is isolated from others. They mention that currently, Appwrite does not support multi-tenancy. They ask if there's a solution currently or if it will be supported in the future. They receive suggestions to use JWT authentication instead of API keys and to grant access to specific users or teams. The user also asks about automatically provisioning a Docker for each customer. The solution provided is to authenticate users individually and grant access to specific users or teams. There is no
D5
15 May, 2023, 16:57

You can grant access to a document only to a specific user and allow read/edit/delete only to a specific person or just the creator, that way, nobody else will have access. Teams is to manage permissions of a group of persons

D5
15 May, 2023, 16:59

So if you just need to grant access to one person, the don't create a team

oferardi
15 May, 2023, 17:14

I need to update documents thru the rest api. The information is of a team (customer) and not of specific user.

The issue is that the api key is not limited to a team and provides access to entire project

This can be a security leakage if multipile customers are using same app/system...

What is the solution for that? Thanks

D5
15 May, 2023, 17:47

The solution is authenticating the user individually, instead of using the API key

oferardi
15 May, 2023, 18:05

For each customer I'll have a local service that needs to write to documents of his specific team access only. Authenticating by user :

  1. User can be deleted and than this solution won't work. I think that there is way with the api allocate users that are the admin , need to verify it.
  2. Second problem is that user has rate limit. Which can cause that documents won't be updated.
Nevus
15 May, 2023, 18:51

According to the documenting I shall use api key and not jwt token. The documentation means that only for creating the database or collection and not for updating a document. So the general flow is:

  1. User registers to your app.
  2. During the registration, you make a call to a backend (which can be a appwrite function).
  3. You authenticate the requests. You can use jwt tokens for this and make any additional checks such as making sure they haven't created a database before.
  4. You create a database for the user with appropriate permissions.
  5. You do updates as D5 suggested.
D5
15 May, 2023, 18:52

Also the user will not be deleted unless if you delete it

D5
15 May, 2023, 18:53

Or the user deleted itself

Nevus
15 May, 2023, 18:53

As for the rate limit, there isn't one for creating a document/collection. The rate limit for updating is 120 requests/second for each user which should be more than enough for most use cases.

oferardi
15 May, 2023, 22:00

The service that will use the rest api is a windows service and not a mobile app/web app.. that's the reason I tried to find different solution than authentication with jwt.. I understand that this is the only available solution. Thank you

Nevus
15 May, 2023, 22:02

You could make plain HTTP requests.

Nevus
15 May, 2023, 22:04

I am sorry but it looks like I misunderstood. Why would you need jwt authentication?

Ponguta_
16 May, 2023, 00:10

Using plain HTTP requests can do the trick, you can store the cookie and use it

oferardi
16 May, 2023, 16:29

My conclusion is that currently appwrite is not supporting application of multi tenancy.

What is missing is that the apikey will have permission for specific "team" and to entire project otherwise its a Security breach.

According to the documention the users api requires api key, only acount api support jwt.

I need that my app will be able to manage whole users of a team (create, list, delete) and excute crud operations but won't have access to other teams resources.

Is this currently supported? Or going to be supported?

This very critical for my customers from cybersecuirty aspects that the customer data will be isolated from other customers.

I would like to work with appwrite and I'm not sure that it currently mature for such an application.

Please advice

Thanks

https://dev.to/appwrite/30daysofappwrite-accounts-users-api-4592

oferardi
16 May, 2023, 17:31

multi tenancy / teams resources isolation

Drake
16 May, 2023, 17:32

you should be accessing data as a user (session/jwt) and access should be restricted based on teams

oferardi
16 May, 2023, 17:36

Is there is any list which api's are supported in this way? Or whole of them will work according the team permission? Thank you Stevan

Drake
16 May, 2023, 17:37

what do you mean?

oferardi
16 May, 2023, 17:42

My application need to manage team users and crud from a client side? Is it possible?

Drake
16 May, 2023, 18:19

use an Appwrite Function to expose limited operations client side

oferardi
16 May, 2023, 18:20

Thanks i'll try it out

oferardi
16 May, 2023, 19:57

P.s. - do you have any example for such implementation?

oferardi
16 May, 2023, 20:37

Thank you very much for your assistant and support

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more