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

Add missing condition for permission checks on spaces #3109

Merged
merged 3 commits into from
Jul 29, 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
5 changes: 5 additions & 0 deletions changelog/unreleased/add-missing-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Fix missing check in MustCheckNodePermissions

We added a missing check to the MustCheckNodePermissions function, so space managers can see disabled spaces.

https://github.com/cs3org/reva/pull/3109
2 changes: 2 additions & 0 deletions pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provide
func (fs *Decomposedfs) MustCheckNodePermissions(ctx context.Context, requestedUserID string, unrestricted bool) bool {
canListAllSpaces := fs.canListAllSpaces(ctx)
switch {
case canListAllSpaces && !unrestricted:
return true
case (canListAllSpaces && requestedUserID == userIDAny):
// admins should not see any other spaces when they request their own, without settings filters
return true
Expand Down
8 changes: 6 additions & 2 deletions pkg/storage/utils/decomposedfs/spaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,18 @@ var _ = Describe("Spaces", func() {
})

Context("needs to check node permissions", func() {
It("returns false on requesting for other user with canlistallspaces und no unrestricted privilege", func() {
resp := env.Fs.MustCheckNodePermissions(env.Ctx, helpers.User0ID, false)
Expect(resp).To(Equal(true))
})
It("returns true on requesting for other user as non-admin", func() {
ctx := ruser.ContextSetUser(context.Background(), env.Users[0])
resp := env.Fs.MustCheckNodePermissions(ctx, helpers.User1ID, false)
Expect(resp).To(Equal(true))
})
It("returns false on requesting for other user as admin", func() {
It("returns true on requesting for other user as admin", func() {
resp := env.Fs.MustCheckNodePermissions(env.Ctx, helpers.User0ID, false)
Expect(resp).To(Equal(false))
Expect(resp).To(Equal(true))
})
It("returns true on requesting for own spaces", func() {
ctx := ruser.ContextSetUser(context.Background(), env.Users[0])
Expand Down