Skip to content

Commit

Permalink
Fix list space permissions (#3084)
Browse files Browse the repository at this point in the history
* revert logic change

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* fix typo

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* fix v2.7.1 changelog

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* add changelog

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* fill in storage provider id if it is missing

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>

* update changelog reflect all commits

Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed Jul 18, 2022
1 parent 0517511 commit 6b31c62
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ Details

https://github.com/owncloud/reva/issues/3080

* Enhancement #4072: Add user filter
* Enhancement #3046: Add user filter

This PR adds the ability to filter spaces by user-id

https://github.com/owncloud/ocis/pull/4072
https://github.com/cs3org/reva/pull/3046


Changelog for reva 2.6.1 (2022-06-27)
Expand Down
2 changes: 1 addition & 1 deletion changelog/2.7.1_2022-07-15/add-user-filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ Enhancement: Add user filter

This PR adds the ability to filter spaces by user-id

https://github.com/owncloud/ocis/pull/4072
https://github.com/cs3org/reva/pull/3046
4 changes: 2 additions & 2 deletions changelog/NOTE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Details

https://github.com/owncloud/reva/issues/3080

* Enhancement #4072: Add user filter
* Enhancement #3046: Add user filter

This PR adds the ability to filter spaces by user-id

https://github.com/owncloud/ocis/pull/4072
https://github.com/cs3org/reva/pull/3046


5 changes: 5 additions & 0 deletions changelog/unreleased/fix-can-list-all-spaces-permission.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: spaces relatated permissions and providerid cleanup

Following the CS3 resource id refactoring we reverted a logic check when checking the list all spaces permission, fixed some typos and made the storageprovider fill in a missing storage provider id.

https://github.com/cs3org/reva/pull/3084
4 changes: 2 additions & 2 deletions docs/content/en/docs/changelog/2.7.1/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ Details

https://github.com/owncloud/reva/issues/3080

* Enhancement #4072: Add user filter
* Enhancement #3046: Add user filter

This PR adds the ability to filter spaces by user-id

https://github.com/owncloud/ocis/pull/4072
https://github.com/cs3org/reva/pull/3046


4 changes: 4 additions & 0 deletions internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ func (s *service) InitiateFileDownload(ctx context.Context, req *provider.Initia
protocol := &provider.FileDownloadProtocol{Expose: s.conf.ExposeDataServer}

if utils.IsRelativeReference(req.Ref) {
// fill in storage provider id if it is missing
if req.GetRef().GetResourceId().GetStorageId() == "" {
req.GetRef().GetResourceId().StorageId = s.conf.MountID
}
protocol.Protocol = "spaces"
u.Path = path.Join(u.Path, "spaces", storagespace.FormatResourceID(*req.Ref.ResourceId), req.Ref.Path)
} else {
Expand Down
5 changes: 5 additions & 0 deletions pkg/rhttp/datatx/utils/download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ func GetOrHeadFile(w http.ResponseWriter, r *http.Request, fs storage.FS, spaceI
return
}

// fill in storage provider id if it is missing
if spaceID != "" && md.GetId().GetStorageId() == "" {
md.Id.StorageId = ref.ResourceId.StorageId
}

var ranges []HTTPRange

if r.Header.Get("Range") != "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
return nil, errtypes.PermissionDenied(fmt.Sprintf("user %s is not allowed to list spaces of other users", ctxpkg.ContextMustGetUser(ctx).GetId().GetOpaqueId()))
}

checkNodePermissions := !canListAllSpaces && !unrestricted
checkNodePermissions := !canListAllSpaces || !unrestricted

spaces := []*provider.StorageSpace{}
// build the glob path, eg.
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/utils/decomposedfs/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (t *Tree) moveSpaceType(spaceType string) error {
Str("space", spaceType).
Str("nodes", child.Name()).
Str("oldLink", old).
Msg("could not read old symplink")
Msg("could not read old symlink")
continue
}
newDir := filepath.Join(t.root, "indexes", "by-type", spaceType)
Expand All @@ -163,7 +163,7 @@ func (t *Tree) moveSpaceType(spaceType string) error {
Str("space", spaceType).
Str("nodes", child.Name()).
Str("targetDir", newDir).
Msg("could not read old symplink")
Msg("could not read old symlink")
}
newLink := filepath.Join(newDir, child.Name())
if err := os.Symlink(filepath.Join("..", target), newLink); err != nil {
Expand Down

0 comments on commit 6b31c62

Please sign in to comment.