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

List public shares only created by the current user #1042

Merged
merged 2 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/publicshares-list-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: List public shares only created by the current user

When running ocis, the public links created by a user are visible to all the
users under the 'Shared with others' tab. This PR fixes that by returning only
those links which are created by a user themselves.

https://github.com/cs3org/reva/pull/1042
5 changes: 5 additions & 0 deletions pkg/publicshare/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ func (m *manager) ListPublicShares(ctx context.Context, u *user.User, filters []
return nil, err
}

// Skip if the share isn't created by the current user
if local.Creator.GetOpaqueId() != u.Id.OpaqueId || (local.Creator.GetIdp() != "" && u.Id.Idp != local.Creator.GetIdp()) {
continue
}

if len(filters) == 0 {
shares = append(shares, &local.PublicShare)
} else {
Expand Down
18 changes: 11 additions & 7 deletions pkg/publicshare/manager/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,17 @@ func (m *manager) ListPublicShares(ctx context.Context, u *user.User, filters []
shares := []*link.PublicShare{}
m.shares.Range(func(k, v interface{}) bool {
s := v.(*link.PublicShare)
if len(filters) == 0 {
shares = append(shares, s)
} else {
for _, f := range filters {
if f.Type == link.ListPublicSharesRequest_Filter_TYPE_RESOURCE_ID {
if s.ResourceId.StorageId == f.GetResourceId().StorageId && s.ResourceId.OpaqueId == f.GetResourceId().OpaqueId {
shares = append(shares, s)

// Skip if the share isn't created by the current user
if s.Creator.GetOpaqueId() == u.Id.OpaqueId && (s.Creator.GetIdp() == "" || u.Id.Idp == s.Creator.GetIdp()) {
if len(filters) == 0 {
shares = append(shares, s)
} else {
for _, f := range filters {
if f.Type == link.ListPublicSharesRequest_Filter_TYPE_RESOURCE_ID {
if s.ResourceId.StorageId == f.GetResourceId().StorageId && s.ResourceId.OpaqueId == f.GetResourceId().OpaqueId {
shares = append(shares, s)
}
}
}
}
Expand Down