fix(portal): collection share revoke and shared thumbnail access#485
Merged
Conversation
The revokeShare handler assumed every share had an AssetID and verified ownership via the asset. Collection shares have CollectionID instead, so the asset lookup returned 404 on every DELETE attempt. The collection thumbnail endpoint checked authentication but not authorization, so users with valid share grants got 403 when loading thumbnails for shared collections.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #485 +/- ##
=======================================
Coverage 86.18% 86.18%
=======================================
Files 237 237
Lines 33005 33025 +20
=======================================
+ Hits 28444 28464 +20
Misses 3301 3301
Partials 1260 1260 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
revokeShareassumed every share had anAssetIDand verified ownership via the asset. Collection shares haveCollectionIDinstead, so the asset lookup failed.getCollectionThumbnailchecked authentication but not share-based authorization.What changed
pkg/portal/handler.gorevokeSharenow branches onshare.CollectionID: if set, ownership is verified against the collection viaverifyCollectionOwner; otherwise the existing asset-ownership path runs. The store'sRevokemethod was already generic (operates on share ID), so no store changes were needed.pkg/portal/collection_handler.gogetCollectionThumbnailnow checkscoll.OwnerID != user.UserIDand falls back tocollectionSharePermissionbefore serving the image, matching the pattern used bygetCollection.pkg/admin/system.go,pkg/admin/system_test.goRemoved vendor-specific names from code comments.
Test plan
TestRevokeCollectionShare/owner_can_revoke- owner successfully revokes a collection shareTestRevokeCollectionShare/non_owner_forbidden- non-owner gets 403TestRevokeCollectionShare/collection_not_found- missing collection gets 404TestGetCollectionThumbnail_SharedUser/shared_user_can_view- user with share grant gets the thumbnailTestGetCollectionThumbnail_SharedUser/non_shared_user_forbidden- user without share grant gets 403make verifycore checks pass (fmt, test/race, lint, security, coverage, patch coverage 91.2%)