Skip to content

Commit

Permalink
Use ocs permission objects in the reva GRPC client
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Jan 27, 2022
1 parent b3f53a1 commit 08dae44
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 41 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/share-create-perm-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Use ocs permission objects in the reva GRPC client

There was a bug introduced by differing CS3APIs permission definitions
for the same role across services. This is a first step in making
all services use consistent definitions.

https://github.com/cs3org/reva/pull/2478
1 change: 0 additions & 1 deletion cmd/reva/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (

const (
viewerPermission string = "viewer"
readerPermission string = "reader"
editorPermission string = "editor"
collabPermission string = "collab"
denyPermission string = "denied"
Expand Down
44 changes: 4 additions & 40 deletions cmd/reva/share-create.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
collaboration "github.com/cs3org/go-cs3apis/cs3/sharing/collaboration/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/internal/http/services/owncloud/ocs/conversions"
"github.com/cs3org/reva/pkg/utils"
"github.com/jedib0t/go-pretty/table"
"github.com/pkg/errors"
Expand Down Expand Up @@ -158,48 +159,11 @@ func getGrantType(t string) provider.GranteeType {
func getSharePerm(p string) (*provider.ResourcePermissions, error) {
switch p {
case viewerPermission:
return &provider.ResourcePermissions{
GetPath: true,
ListContainer: true,
Stat: true,
}, nil
case readerPermission:
return &provider.ResourcePermissions{
GetPath: true,
InitiateFileDownload: true,
ListFileVersions: true,
ListContainer: true,
Stat: true,
}, nil
return conversions.NewViewerRole().CS3ResourcePermissions(), nil
case editorPermission:
return &provider.ResourcePermissions{
GetPath: true,
InitiateFileDownload: true,
ListFileVersions: true,
ListContainer: true,
Stat: true,
CreateContainer: true,
Delete: true,
InitiateFileUpload: true,
RestoreFileVersion: true,
Move: true,
}, nil
return conversions.NewEditorRole().CS3ResourcePermissions(), nil
case collabPermission:
return &provider.ResourcePermissions{
GetPath: true,
InitiateFileDownload: true,
ListFileVersions: true,
ListContainer: true,
Stat: true,
CreateContainer: true,
Delete: true,
InitiateFileUpload: true,
RestoreFileVersion: true,
Move: true,
AddGrant: true,
UpdateGrant: true,
RemoveGrant: true,
}, nil
return conversions.NewCoownerRole().CS3ResourcePermissions(), nil
case denyPermission:
return &provider.ResourcePermissions{}, nil
default:
Expand Down

0 comments on commit 08dae44

Please sign in to comment.