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

Fix list space permissions #3084

Merged
merged 6 commits into from
Jul 18, 2022
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
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()))
micbar marked this conversation as resolved.
Show resolved Hide resolved
}

checkNodePermissions := !canListAllSpaces && !unrestricted
checkNodePermissions := !canListAllSpaces || !unrestricted
micbar marked this conversation as resolved.
Show resolved Hide resolved

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