Repository navigation
Closed
Description
Describe the bug
Creating a share with roles such as Uploader, Viewer, Editor, Manager, or Co-owner is possible. However, when attempting to send an API request to update roles, a "400 Bad Request" error is encountered.
Steps to reproduce
- send share invitation of
file.txtwith any roles result successful share invite - try to update the role to
manager/co-owner/uploader/Editor(for file or folder)results 400 status code
try to change role from Co Owner to Uploader
curl --location --request PATCH 'https://ocis.owncloud.test/graph/v1beta1/drives/drive-id/items/item-id/permissions/permission-id' \
--header 'Authorization: Bearer eyJhbVKA' \
--data '{
"roles": [
"1c996275-f1c9-4e71-abdf-a42f6495e960"
]
}'
{
"error": {
"code": "invalidRequest",
"innererror": {
"date": "2024-01-04T11:55:00Z",
"request-id": "8bce2c34615e/b9ocmAsArN-002634"
},
"message": "cannot set the requested permissions on that type of resource"
}
}
Cases
| Role while creating share | Role to update | Result |
|---|---|---|
| Manager/Viewer/Co Owner | Editor | ✅ Success |
| Manager/Editor/Co Owner | Viewer | ✅ Success |
| Manager/Editor/Viewer/Uploader | Co-owner | 400 Status |
| Manager/Co Owner/Editor/Viewer | Uploader | 400 Status |
Expected behavior
We cannot use all roles on all resource types.
The roles have conditions. Some can only be applied to space roots some only to shares.
During share invite, only allowed role should be set
Actual behavior
Can set any role during share invite.
Personal Drive File resource should not allowed to create share invite with role Co owner/Uploader
Setup
Please describe how you started the server and provide a list of relevant environment variables or configuration files.
Details
OCIS_Version= 5.1.0-prealpha+0f9f996abAdditional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
micbar commentedon Jan 4, 2024
The expected behavior is not correct.
We cannot use all roles on all resource types.
The roles have conditions. Some can only be applied to space roots some only to shares.
but the clients do not need any Knowledge about that. Before creating or updating a permission, they should check what is possible on that specific resource. This is the needed api call https://owncloud.dev/libre-graph-api/#/drives.permissions/ListPermissions
amrita-shrestha commentedon Jan 5, 2024
@micbar
If roles are specified according to resource type then during share invite user should not allowed to set role that resource doesn't support. Isn't it?
[-]Update role gives 400 error for `Manger/Co Owner/Uploader/Editor`[/-][+]Any role can be set during share invite request[/+]micbar commentedon Jan 5, 2024
What is the response of api call https://owncloud.dev/libre-graph-api/#/drives.permissions/ListPermissions on the two different cases?
IMO the test should use the response from api call https://owncloud.dev/libre-graph-api/#/drives.permissions/ListPermissions and check if the allowed roles are possible to apply.
amrita-shrestha commentedon Jan 10, 2024
@micbar
abc.txtCo-Owner/Manger/Uploader/Editor/Viewercurl -vk 'https://host.docker.internal:9200/graph/v1beta1/drives/{drives-id}/items/{items-id}/permissions'curl -vk 'https://host.docker.internal:9200/graph/v1beta1/drives/{drive-id}/items/{item-id}/invite' \ --data '{ "recipients": [ { "objectId": "dc3b93f7-f77f-4551-a783-625504af7d77" } ], "roles": [ "3a4ba8e9-6a0d-4235-9140-0e7a34007abe" ] }'co-ownerrole will be displayed as set rolecurl -vk 'https://host.docker.internal:9200/graph/v1beta1/drives/{drives-id}/items/{items-id}/permissionsabcmicbar commentedon Jan 10, 2024
@rhafer seems that our allowed roles are not yet scoped.
rhafer commentedon Jan 17, 2024
related #6993
rhafer commentedon Jan 18, 2024
Seems there are two bugs here:
usershareprovider: Prevent setting container specific permissions on …
graph/sharing: Add check for role conditions
graph/sharing: Add check for role conditions
graph/sharing: Add check for role conditions
graph/sharing: Add check for role conditions
graph/sharing: Add check for role conditions