Rank 2: Process
Is it possible to do a server side check of the user permissions? For example, I want to know if a specific user has permission to write on a certain document. How can I do it?
Votes
1
Replies
18
Participants
Unknown
Messages
19
Rank 2: Process
Is it possible to do a server side check of the user permissions? For example, I want to know if a specific user has permission to write on a certain document. How can I do it?
From what I've seen, it seems like this option is not yet implanted, so you'll have to make some workaround with custom attributes
You can see a discussion about it here
https://discord.com/channels/564160730845151244/1100734700814872637
Rank 2: Process
I don't want to make actions on the behalf of the user, I just want to know if it has the permission to do certain actions
Ohh,
Something like this for example?
const user = await getUser(id);
if(user.can('write','databaseNane.colletionName')) { // Logic go's here }Rank 2: Process
Yes
Rank 2: Process
Exactly
That sounds like something that will add a lot to Appwrite user functions,
I don't recall to be something about it.
You can open an issue for it
https://github.com/appwrite/appwrite/issues
From my quick search, I didn't find any other issues with this
Rank 2: Process
Wierd, it looks like a common usecase to me
Rank 4: Virtual Machine
Appwrite vision = all client actions from client sdk (that take into account the permissions)
Rank 2: Process
I don't want to do a client action, I just want to do a security check
Rank 3: Container
Hello @Iron by writing on certain document you mean like update/delete that document?
Otherwise, are you talking about collections?
If you have not so many documents you can use a workaround like this, sorry if it is janky, but I have never think about it before.
database = databases.Databases(client)user = users.Users(client)
id_user = '64492ce6569089ef247e'aux_user = user.get(id_user)list_docs = database.list_documents('data', 'new_collection')
for i in list_docs["documents"]: for j in i["$permissions"]: if (aux_user["$id"] in str(j)): print(aux_user["name"], "has", j.split("(")[0], "permission in document", i["$id"])Outcome:
user 1 has read permission in document 64492d5ba2ac1a0e3b99
user 1 has update permission in document 64492d5ba2ac1a0e3b99
user 1 has delete permission in document 64492d5ba2ac1a0e3b99
Rank 4: Virtual Machine
I created issue for you : https://github.com/appwrite/appwrite/issues/5434
Rank 4: Virtual Machine
You can upvote it
Cool 👍
Rank 3: Container
Nice!
Rank 2: Process
I already know the document id, I didn't thought of doing it this way, thank you!
Rank 3: Container
You are welcome!
Rank 2: Process
Thank you!