Skip to content

Commit

Permalink
enable space member to update share
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christofas committed Sep 5, 2022
1 parent 113fdea commit 6c59da2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog/unreleased/update-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: enable space members to update shares

Enabled space members to update shares which they have not created themselves.

https://github.com/cs3org/reva/pull/3192
13 changes: 12 additions & 1 deletion pkg/share/manager/jsoncs3/jsoncs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,13 @@ func (m *Manager) GetShare(ctx context.Context, ref *collaboration.ShareReferenc
if share.IsCreatedByUser(s, user) || share.IsGrantedToUser(s, user) {
return s, nil
}

shares := m.Cache.ListSpace(s.ResourceId.StorageId, s.ResourceId.SpaceId)
if _, ok := shares.Shares[s.GetId().GetOpaqueId()]; ok {
// Members of a space are also allowed to list the share.
return s, nil
}

// we return not found to not disclose information
return nil, errtypes.NotFound(ref.String())
}
Expand Down Expand Up @@ -425,7 +432,11 @@ func (m *Manager) UpdateShare(ctx context.Context, ref *collaboration.ShareRefer

user := ctxpkg.ContextMustGetUser(ctx)
if !share.IsCreatedByUser(s, user) {
return nil, errtypes.NotFound(ref.String())
shares := m.Cache.ListSpace(s.ResourceId.StorageId, s.ResourceId.SpaceId)
// Members of a space are also allowed to list the share.
if _, ok := shares.Shares[s.GetId().GetOpaqueId()]; !ok {
return nil, errtypes.NotFound(ref.String())
}
}

s.Permissions = p
Expand Down

0 comments on commit 6c59da2

Please sign in to comment.