I want to create a document that has also the read permission for a other user. When I try to achive this with:
Permission.read(Role.user(entry.userid)),
Permission.read(Role.user(entry.enemyid)),
I get the error "Permission must be one of: (any, users, user:OWN USER ID").
When I add the permission from the web panel everything works fine. Document Security is enabled and the collection permissions are set to users create enabled.
Hey there 👋 This is expected behaviour for security reasons.
Imagine there was notifications
collection. If I could spam anyones notification inbox by giving them read permissions, it would be pretty bad experience for them.
Some possible solutions:
- Use Teams. Put users into same team (other person needs to accept), and you can now give permission to the team
- Use Functions. Write a function that would set the permission to specific user. Functions are allowed to do anything. Then, call this function using
createExecution
Okay thanks. Can I also use the server SDK? Like a REST request with a api key?
Yes, that's exactly what Appwrite Function would do. Tho make sure API key is not visible to the client, otherwise they could hack your whole project.
You can do this by for example:
- Running in Appwrite Function
- Running on your api server (python, nodeJS, Deno, ..)
- Running in SSR (possible in most meta web frameworks)
Okay thanks a lot.
[SOLVED] Permissions must be one of: (any, users, user:X)