Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-owners to remove themselves from a shared asset #2945

Merged
merged 7 commits into from Jan 30, 2021

Conversation

joshuaberetta
Copy link
Member

@joshuaberetta joshuaberetta commented Jan 5, 2021

Permissions on the DELETE method of the existing permission-assignments endpoint have been modified to allow for non-owners of a shared asset to always be able to remove themselves from the asset:

DELETE /api/v2/assets/{uid}/permission-assignments/{permission_uid}/

Non-owners can remove their own permissions, but are not able to delete the permissions of the asset's owner or any other non-owners who may have the asset shared with them.

Description

This change allows users with view_asset to permissions to remove themselves from an asset that has been shared with them as requested in the community forum.

Related issues

closes #2940

@joshuaberetta joshuaberetta added Back end enhancement Ideas, improvements and features API Changes related to API endpoints labels Jan 5, 2021
@joshuaberetta joshuaberetta linked an issue Jan 5, 2021 that may be closed by this pull request
@joshuaberetta joshuaberetta changed the title [WIP] Allow non-owners to remove themselves from a shared asset Allow non-owners to remove themselves from a shared asset Jan 5, 2021
@joshuaberetta joshuaberetta marked this pull request as ready for review January 5, 2021 21:18
@joshuaberetta joshuaberetta requested a review from jnm January 5, 2021 21:18
kpi/tests/api/v2/test_api_permissions.py Outdated Show resolved Hide resolved
kpi/tests/api/v2/test_api_permissions.py Outdated Show resolved Hide resolved
kpi/tests/api/v2/test_api_permissions.py Outdated Show resolved Hide resolved
kpi/tests/api/v2/test_api_permissions.py Outdated Show resolved Hide resolved
kpi/tests/api/v2/test_api_permissions.py Outdated Show resolved Hide resolved
kpi/views/v2/asset_permission_assignment.py Outdated Show resolved Hide resolved
kpi/permissions.py Show resolved Hide resolved
* This change allows users with `view_asset` to permissions to
remove themselves from an asset that has been shared with them
* The new condition ensures that if the user attempting to perform the
delete is not the owner of the asset and is trying to delete permissions
for anyone but themselves, a 'permission denied' error is raised.
* Ensuring that a non-owner can remove themselves from an asset shared
with them
* Ensuring that a non-owner who has been shared an asset cannot remove
permissions of the owner of that asset
* Ensuring that a one non-owner cannot remove the permissions of another
non-owner who has also been shared the same asset
@joshuaberetta joshuaberetta force-pushed the 2940-allow-non-owners-to-remove-their-own-permissions branch from c72f4e3 to b12ef8f Compare January 21, 2021 20:06
Base automatically changed from 2332-collection-as-asset-type to beta January 30, 2021 07:05
Comment on lines +290 to +292
perm = ObjectPermission.objects.filter(asset=new_asset).get(
user=self.someuser, permission__codename=PERM_VIEW_ASSET
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jnm jnm merged commit d6996fd into beta Jan 30, 2021
@jnm jnm deleted the 2940-allow-non-owners-to-remove-their-own-permissions branch January 30, 2021 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Changes related to API endpoints Back end enhancement Ideas, improvements and features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Always allow non-owners to remove their own permissions
2 participants