diff --git a/changelog/unreleased/remove-resharing.md b/changelog/unreleased/remove-resharing.md new file mode 100644 index 00000000000..2fd1e25a958 --- /dev/null +++ b/changelog/unreleased/remove-resharing.md @@ -0,0 +1,5 @@ +Enhancement: Remove resharing + +Removed all code related to resharing + +https://github.com/cs3org/reva/pull/4606 diff --git a/internal/grpc/services/ocmshareprovider/ocmshareprovider.go b/internal/grpc/services/ocmshareprovider/ocmshareprovider.go index 0f68136fdfb..5c5824540c1 100644 --- a/internal/grpc/services/ocmshareprovider/ocmshareprovider.go +++ b/internal/grpc/services/ocmshareprovider/ocmshareprovider.go @@ -327,7 +327,7 @@ func (s *service) CreateOCMShare(ctx context.Context, req *ocm.CreateOCMShareReq ProviderID: ocmshare.Id.OpaqueId, Owner: formatOCMUser(&userpb.UserId{ OpaqueId: info.Owner.OpaqueId, - Idp: s.conf.ProviderDomain, // FIXME: this is not generally true in case of resharing + Idp: s.conf.ProviderDomain, }), Sender: formatOCMUser(&userpb.UserId{ OpaqueId: user.Id.OpaqueId, diff --git a/internal/grpc/services/publicshareprovider/publicshareprovider.go b/internal/grpc/services/publicshareprovider/publicshareprovider.go index 3df749f8823..b987b96acf6 100644 --- a/internal/grpc/services/publicshareprovider/publicshareprovider.go +++ b/internal/grpc/services/publicshareprovider/publicshareprovider.go @@ -593,7 +593,7 @@ func isInternalLink(req *link.UpdatePublicShareRequest, ps *link.PublicShare) bo } func enforcePassword(canOptOut bool, permissions *provider.ResourcePermissions, conf *config) bool { - isReadOnly := conversions.SufficientCS3Permissions(conversions.NewViewerRole(true).CS3ResourcePermissions(), permissions) + isReadOnly := conversions.SufficientCS3Permissions(conversions.NewViewerRole().CS3ResourcePermissions(), permissions) if isReadOnly && canOptOut { return false } diff --git a/internal/grpc/services/usershareprovider/usershareprovider.go b/internal/grpc/services/usershareprovider/usershareprovider.go index 0c503e7cc29..45487c9cfac 100644 --- a/internal/grpc/services/usershareprovider/usershareprovider.go +++ b/internal/grpc/services/usershareprovider/usershareprovider.go @@ -55,7 +55,6 @@ type config struct { Drivers map[string]map[string]interface{} `mapstructure:"drivers"` GatewayAddr string `mapstructure:"gateway_addr"` AllowedPathsForShares []string `mapstructure:"allowed_paths_for_shares"` - DisableResharing bool `mapstructure:"disable_resharing"` } func (c *config) init() { @@ -68,7 +67,6 @@ type service struct { sm share.Manager gatewaySelector pool.Selectable[gateway.GatewayAPIClient] allowedPathsForShares []*regexp.Regexp - disableResharing bool } func getShareManager(c *config) (share.Manager, error) { @@ -129,16 +127,15 @@ func NewDefault(m map[string]interface{}, ss *grpc.Server) (rgrpc.Service, error return nil, err } - return New(gatewaySelector, sm, allowedPathsForShares, c.DisableResharing), nil + return New(gatewaySelector, sm, allowedPathsForShares), nil } // New creates a new user share provider svc -func New(gatewaySelector pool.Selectable[gateway.GatewayAPIClient], sm share.Manager, allowedPathsForShares []*regexp.Regexp, disableResharing bool) rgrpc.Service { +func New(gatewaySelector pool.Selectable[gateway.GatewayAPIClient], sm share.Manager, allowedPathsForShares []*regexp.Regexp) rgrpc.Service { service := &service{ sm: sm, gatewaySelector: gatewaySelector, allowedPathsForShares: allowedPathsForShares, - disableResharing: disableResharing, } return service @@ -160,10 +157,10 @@ func (s *service) CreateShare(ctx context.Context, req *collaboration.CreateShar log := appctx.GetLogger(ctx) user := ctxpkg.ContextMustGetUser(ctx) - // when resharing is disabled grants must not allow grant permissions - if s.disableResharing && HasGrantPermissions(req.GetGrant().GetPermissions().GetPermissions()) { + // Grants must not allow grant permissions + if HasGrantPermissions(req.GetGrant().GetPermissions().GetPermissions()) { return &collaboration.CreateShareResponse{ - Status: status.NewInvalidArg(ctx, "resharing not supported"), + Status: status.NewInvalidArg(ctx, "resharing not allowed"), }, nil } @@ -342,10 +339,10 @@ func (s *service) UpdateShare(ctx context.Context, req *collaboration.UpdateShar log := appctx.GetLogger(ctx) user := ctxpkg.ContextMustGetUser(ctx) - // when resharing is disabled grants must not allow grant permissions - if s.disableResharing && HasGrantPermissions(req.GetShare().GetPermissions().GetPermissions()) { + // Grants must not allow grant permissions + if HasGrantPermissions(req.GetShare().GetPermissions().GetPermissions()) { return &collaboration.UpdateShareResponse{ - Status: status.NewInvalidArg(ctx, "resharing not supported"), + Status: status.NewInvalidArg(ctx, "resharing not allowed"), }, nil } diff --git a/internal/grpc/services/usershareprovider/usershareprovider_test.go b/internal/grpc/services/usershareprovider/usershareprovider_test.go index 7b958eda4c3..7d675d1b97c 100644 --- a/internal/grpc/services/usershareprovider/usershareprovider_test.go +++ b/internal/grpc/services/usershareprovider/usershareprovider_test.go @@ -183,10 +183,9 @@ var _ = Describe("user share provider service", func() { 0, ), ) - Context("resharing disabled", func() { + Context("resharing is not allowed", func() { JustBeforeEach(func() { - // disable resharing - rgrpcService := usershareprovider.New(gatewaySelector, manager, []*regexp.Regexp{}, true) + rgrpcService := usershareprovider.New(gatewaySelector, manager, []*regexp.Regexp{}) provider = rgrpcService.(collaborationpb.CollaborationAPIServer) Expect(provider).ToNot(BeNil()) diff --git a/internal/http/services/owncloud/ocs/data/capabilities.go b/internal/http/services/owncloud/ocs/data/capabilities.go index 369ca231792..d788a4a8e6c 100644 --- a/internal/http/services/owncloud/ocs/data/capabilities.go +++ b/internal/http/services/owncloud/ocs/data/capabilities.go @@ -209,7 +209,6 @@ type CapabilitiesDav struct { // CapabilitiesFilesSharing TODO document type CapabilitiesFilesSharing struct { APIEnabled ocsBool `json:"api_enabled" xml:"api_enabled" mapstructure:"api_enabled"` - Resharing ocsBool `json:"resharing" xml:"resharing"` GroupSharing ocsBool `json:"group_sharing" xml:"group_sharing" mapstructure:"group_sharing"` SharingRoles ocsBool `json:"sharing_roles" xml:"sharing_roles" mapstructure:"sharing_roles"` DenyAccess ocsBool `json:"deny_access" xml:"deny_access" mapstructure:"deny_access"` diff --git a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index 694273866e7..71cc2c9c34f 100644 --- a/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -69,8 +69,6 @@ import ( const ( storageIDPrefix string = "shared::" - - _resharingDefault bool = false ) var ( @@ -92,7 +90,6 @@ type Handler struct { userIdentifierCache *ttlcache.Cache statCache cache.StatCache deniable bool - resharing bool publicPasswordEnforced passwordEnforced passwordValidator password.Validator @@ -146,7 +143,6 @@ func (h *Handler) Init(c *config.Config) error { h.userIdentifierCache = ttlcache.NewCache() _ = h.userIdentifierCache.SetTTL(time.Second * time.Duration(c.UserIdentifierCacheTTL)) h.deniable = c.EnableDenials - h.resharing = resharing(c) h.publicPasswordEnforced = publicPwdEnforced(c) h.passwordValidator = passwordPolicies(c) @@ -320,7 +316,7 @@ func (h *Handler) CreateShare(w http.ResponseWriter, r *http.Request) { response.WriteOCSSuccess(w, r, s) case int(conversions.ShareTypePublicLink): // public links default to read only - _, _, ocsErr := h.extractPermissions(reqRole, reqPermissions, statRes.Info, conversions.NewViewerRole(h.resharing)) + _, _, ocsErr := h.extractPermissions(reqRole, reqPermissions, statRes.Info, conversions.NewViewerRole()) if ocsErr != nil && ocsErr.Error != conversions.ErrZeroPermission { response.WriteOCSError(w, r, http.StatusForbidden, "No share permission", nil) return @@ -339,7 +335,7 @@ func (h *Handler) CreateShare(w http.ResponseWriter, r *http.Request) { response.WriteOCSSuccess(w, r, s) case int(conversions.ShareTypeFederatedCloudShare): // federated shares default to read only - if role, val, err := h.extractPermissions(reqRole, reqPermissions, statRes.Info, conversions.NewViewerRole(h.resharing)); err == nil { + if role, val, err := h.extractPermissions(reqRole, reqPermissions, statRes.Info, conversions.NewViewerRole()); err == nil { h.createFederatedCloudShare(w, r, statRes.Info, role, val) } case int(conversions.ShareTypeSpaceMembershipUser), int(conversions.ShareTypeSpaceMembershipGroup): @@ -429,7 +425,7 @@ func (h *Handler) extractPermissions(reqRole string, reqPermissions string, ri * // the share role overrides the requested permissions if reqRole != "" { - role = conversions.RoleFromName(reqRole, h.resharing) + role = conversions.RoleFromName(reqRole) } // if the role is unknown - fall back to reqPermissions or defaultPermissions @@ -1685,10 +1681,3 @@ func sufficientPermissions(existing, requested *provider.ResourcePermissions, is rp := conversions.RoleFromResourcePermissions(requested, islink).OCSPermissions() return ep.Contain(rp) } - -func resharing(c *config.Config) bool { - if c != nil && c.Capabilities.Capabilities != nil && c.Capabilities.Capabilities.FilesSharing != nil { - return bool(c.Capabilities.Capabilities.FilesSharing.Resharing) - } - return _resharingDefault -} diff --git a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities_test.go b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities_test.go index 43ae2afcdc1..96faa977ea8 100644 --- a/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities_test.go +++ b/internal/http/services/owncloud/ocs/handlers/cloud/capabilities/capabilities_test.go @@ -35,8 +35,8 @@ func TestMarshal(t *testing.T) { }, } - jsonExpect := `{"capabilities":{"core":null,"checksums":null,"files":null,"dav":null,"files_sharing":{"api_enabled":true,"resharing":false,"group_sharing":false,"sharing_roles":false,"deny_access":false,"auto_accept_share":false,"share_with_group_members_only":false,"share_with_membership_groups_only":false,"search_min_length":0,"default_permissions":0,"user_enumeration":null,"federation":null,"public":null,"user":null}},"version":null}` - xmlExpect := `1000000000` + jsonExpect := `{"capabilities":{"core":null,"checksums":null,"files":null,"dav":null,"files_sharing":{"api_enabled":true,"group_sharing":false,"sharing_roles":false,"deny_access":false,"auto_accept_share":false,"share_with_group_members_only":false,"share_with_membership_groups_only":false,"search_min_length":0,"default_permissions":0,"user_enumeration":null,"federation":null,"public":null,"user":null}},"version":null}` + xmlExpect := `100000000` jsonData, err := json.Marshal(&cd) if err != nil { diff --git a/internal/http/services/sciencemesh/share.go b/internal/http/services/sciencemesh/share.go index af51c5e6b4e..c5bc78e5629 100644 --- a/internal/http/services/sciencemesh/share.go +++ b/internal/http/services/sciencemesh/share.go @@ -150,9 +150,9 @@ func (h *sharesHandler) CreateShare(w http.ResponseWriter, r *http.Request) { func getPermissionsByRole(role string) (*providerpb.ResourcePermissions, appprovider.ViewMode) { switch role { case "viewer": - return conversions.NewViewerRole(false).CS3ResourcePermissions(), appprovider.ViewMode_VIEW_MODE_READ_ONLY + return conversions.NewViewerRole().CS3ResourcePermissions(), appprovider.ViewMode_VIEW_MODE_READ_ONLY case "editor": - return conversions.NewEditorRole(false).CS3ResourcePermissions(), appprovider.ViewMode_VIEW_MODE_READ_WRITE + return conversions.NewEditorRole().CS3ResourcePermissions(), appprovider.ViewMode_VIEW_MODE_READ_WRITE } return nil, 0 } diff --git a/pkg/cbox/utils/conversions.go b/pkg/cbox/utils/conversions.go index a2cc7d18188..b94b50b3b9b 100644 --- a/pkg/cbox/utils/conversions.go +++ b/pkg/cbox/utils/conversions.go @@ -145,12 +145,12 @@ func SharePermToInt(p *provider.ResourcePermissions) int { func IntTosharePerm(p int, itemType string) *provider.ResourcePermissions { switch p { case 1: - return conversions.NewViewerRole(false).CS3ResourcePermissions() + return conversions.NewViewerRole().CS3ResourcePermissions() case 15: if itemType == "folder" { - return conversions.NewEditorRole(false).CS3ResourcePermissions() + return conversions.NewEditorRole().CS3ResourcePermissions() } - return conversions.NewFileEditorRole(false).CS3ResourcePermissions() + return conversions.NewFileEditorRole().CS3ResourcePermissions() case 4: return conversions.NewUploaderRole().CS3ResourcePermissions() default: diff --git a/pkg/conversions/role.go b/pkg/conversions/role.go index cbde91bffcb..57ab08e1449 100644 --- a/pkg/conversions/role.go +++ b/pkg/conversions/role.go @@ -141,20 +141,20 @@ func (r *Role) WebDAVPermissions(isDir, isShared, isMountpoint, isPublic bool) s } // RoleFromName creates a role from the name -func RoleFromName(name string, sharing bool) *Role { +func RoleFromName(name string) *Role { switch name { case RoleDenied: return NewDeniedRole() case RoleViewer: - return NewViewerRole(sharing) + return NewViewerRole() case RoleSpaceViewer: return NewSpaceViewerRole() case RoleEditor: - return NewEditorRole(sharing) + return NewEditorRole() case RoleSpaceEditor: return NewSpaceEditorRole() case RoleFileEditor: - return NewFileEditorRole(sharing) + return NewFileEditorRole() case RoleUploader: return NewUploaderRole() case RoleManager: @@ -183,15 +183,11 @@ func NewDeniedRole() *Role { } // NewViewerRole creates a viewer role. `sharing` indicates if sharing permission should be added -func NewViewerRole(sharing bool) *Role { +func NewViewerRole() *Role { p := PermissionRead - if sharing { - p |= PermissionShare - } return &Role{ Name: RoleViewer, cS3ResourcePermissions: &provider.ResourcePermissions{ - AddGrant: sharing, GetPath: true, GetQuota: true, InitiateFileDownload: true, @@ -221,15 +217,11 @@ func NewSpaceViewerRole() *Role { } // NewEditorRole creates an editor role. `sharing` indicates if sharing permission should be added -func NewEditorRole(sharing bool) *Role { +func NewEditorRole() *Role { p := PermissionRead | PermissionCreate | PermissionWrite | PermissionDelete - if sharing { - p |= PermissionShare - } return &Role{ Name: RoleEditor, cS3ResourcePermissions: &provider.ResourcePermissions{ - AddGrant: sharing, CreateContainer: true, Delete: true, GetPath: true, @@ -271,15 +263,11 @@ func NewSpaceEditorRole() *Role { } // NewFileEditorRole creates a file-editor role -func NewFileEditorRole(sharing bool) *Role { +func NewFileEditorRole() *Role { p := PermissionRead | PermissionWrite - if sharing { - p |= PermissionShare - } return &Role{ Name: RoleEditor, cS3ResourcePermissions: &provider.ResourcePermissions{ - AddGrant: sharing, GetPath: true, GetQuota: true, InitiateFileDownload: true, @@ -384,21 +372,19 @@ func RoleFromOCSPermissions(p Permissions, ri *provider.ResourceInfo) *Role { if p.Contain(PermissionRead) { if p.Contain(PermissionWrite) && p.Contain(PermissionCreate) && p.Contain(PermissionDelete) { - if p.Contain(PermissionShare) { - return NewEditorRole(true) - } - if isSpaceRoot(ri) { return NewSpaceEditorRole() } + + return NewEditorRole() } if p == PermissionRead && isSpaceRoot(ri) { return NewSpaceViewerRole() } - if p == PermissionRead|PermissionShare && !isSpaceRoot(ri) { - return NewViewerRole(true) + if p == PermissionRead && !isSpaceRoot(ri) { + return NewViewerRole() } } if p == PermissionCreate { diff --git a/pkg/storage/utils/eosfs/eosfs.go b/pkg/storage/utils/eosfs/eosfs.go index 50f9493f802..2d11ecdfa76 100644 --- a/pkg/storage/utils/eosfs/eosfs.go +++ b/pkg/storage/utils/eosfs/eosfs.go @@ -83,8 +83,6 @@ const LockTypeKey = "reva.lock.type" var hiddenReg = regexp.MustCompile(`\.sys\..#.`) -var _resharing = false - func (c *Config) init() { c.Namespace = path.Clean(c.Namespace) if !strings.HasPrefix(c.Namespace, "/") { @@ -2129,12 +2127,12 @@ func (fs *eosfs) permissionSet(ctx context.Context, eosFileInfo *eosclient.FileI // The role names should not be hardcoded any more as they will come from config in the future if publicShare, ok := u.Opaque.Map["public-share-role"]; ok { if string(publicShare.Value) == "editor" { - return conversions.NewEditorRole(_resharing).CS3ResourcePermissions() + return conversions.NewEditorRole().CS3ResourcePermissions() } else if string(publicShare.Value) == "uploader" { return conversions.NewUploaderRole().CS3ResourcePermissions() } // Default to viewer role - return conversions.NewViewerRole(_resharing).CS3ResourcePermissions() + return conversions.NewViewerRole().CS3ResourcePermissions() } } diff --git a/tests/integration/grpc/ocm_share_test.go b/tests/integration/grpc/ocm_share_test.go index 7c21334d928..8d32ebd0b27 100644 --- a/tests/integration/grpc/ocm_share_test.go +++ b/tests/integration/grpc/ocm_share_test.go @@ -687,24 +687,6 @@ var _ = Describe("ocm share", func() { }) Expect(err).ToNot(HaveOccurred()) Expect(createShareRes.Status.Code).To(Equal(rpcv1beta1.Code_CODE_OK)) - - By("resharing the same file with marie") - - createShareRes2, err := cernboxgw.CreateOCMShare(ctxEinstein, &ocmv1beta1.CreateOCMShareRequest{ - ResourceId: info.Id, - Grantee: &provider.Grantee{ - Type: provider.GranteeType_GRANTEE_TYPE_USER, - Id: &provider.Grantee_UserId{ - UserId: federatedMarieID, - }, - }, - AccessMethods: []*ocmv1beta1.AccessMethod{ - share.NewWebDavAccessMethod(conversions.NewEditorRole(false).CS3ResourcePermissions()), - }, - RecipientMeshProvider: cesnet.ProviderInfo, - }) - Expect(err).ToNot(HaveOccurred()) - Expect(createShareRes2.Status.Code).To(Equal(rpcv1beta1.Code_CODE_ALREADY_EXISTS)) }) }) diff --git a/tests/oc-integration-tests/drone/frontend-global.toml b/tests/oc-integration-tests/drone/frontend-global.toml index 6fd2e2bc727..b7b7e6db8ac 100644 --- a/tests/oc-integration-tests/drone/frontend-global.toml +++ b/tests/oc-integration-tests/drone/frontend-global.toml @@ -61,7 +61,6 @@ versionstring = "10.0.11" [http.services.ocs.capabilities.capabilities.files_sharing] api_enabled = true -resharing = true group_sharing = true auto_accept_share = true share_with_group_members_only = true diff --git a/tests/oc-integration-tests/drone/frontend.toml b/tests/oc-integration-tests/drone/frontend.toml index 07679cf7361..fcfd6d25fef 100644 --- a/tests/oc-integration-tests/drone/frontend.toml +++ b/tests/oc-integration-tests/drone/frontend.toml @@ -62,7 +62,6 @@ versionstring = "10.0.11" [http.services.ocs.capabilities.capabilities.files_sharing] api_enabled = true -resharing = true group_sharing = true auto_accept_share = true share_with_group_members_only = true diff --git a/tests/oc-integration-tests/local-mesh/frontend-global.toml b/tests/oc-integration-tests/local-mesh/frontend-global.toml index a98f7e31b24..ca51f4c3c85 100644 --- a/tests/oc-integration-tests/local-mesh/frontend-global.toml +++ b/tests/oc-integration-tests/local-mesh/frontend-global.toml @@ -55,7 +55,6 @@ versionstring = "10.0.11" [http.services.ocs.capabilities.capabilities.files_sharing] api_enabled = true -resharing = true group_sharing = true auto_accept_share = true share_with_group_members_only = true diff --git a/tests/oc-integration-tests/local-mesh/frontend.toml b/tests/oc-integration-tests/local-mesh/frontend.toml index 14a7259bd43..87436854ca3 100644 --- a/tests/oc-integration-tests/local-mesh/frontend.toml +++ b/tests/oc-integration-tests/local-mesh/frontend.toml @@ -57,7 +57,6 @@ versionstring = "10.0.11" [http.services.ocs.capabilities.capabilities.files_sharing] api_enabled = true -resharing = true group_sharing = true auto_accept_share = true share_with_group_members_only = true diff --git a/tests/oc-integration-tests/local/combined.toml b/tests/oc-integration-tests/local/combined.toml index 4b0262e6a76..264c74bb323 100644 --- a/tests/oc-integration-tests/local/combined.toml +++ b/tests/oc-integration-tests/local/combined.toml @@ -136,7 +136,6 @@ versionstring = "10.0.11" [http.services.ocs.capabilities.capabilities.files_sharing] api_enabled = true -resharing = true group_sharing = true auto_accept_share = true share_with_group_members_only = true diff --git a/tests/oc-integration-tests/local/frontend-global.toml b/tests/oc-integration-tests/local/frontend-global.toml index 2c8c1a254ca..d9b7c319475 100644 --- a/tests/oc-integration-tests/local/frontend-global.toml +++ b/tests/oc-integration-tests/local/frontend-global.toml @@ -62,7 +62,6 @@ versionstring = "10.0.11" [http.services.ocs.capabilities.capabilities.files_sharing] api_enabled = true -resharing = true group_sharing = true auto_accept_share = true share_with_group_members_only = true diff --git a/tests/oc-integration-tests/local/frontend.toml b/tests/oc-integration-tests/local/frontend.toml index 86071204f99..a6d4a9786ec 100644 --- a/tests/oc-integration-tests/local/frontend.toml +++ b/tests/oc-integration-tests/local/frontend.toml @@ -70,7 +70,6 @@ versionstring = "10.0.11" [http.services.ocs.capabilities.capabilities.files_sharing] api_enabled = true -resharing = true group_sharing = true auto_accept_share = true share_with_group_members_only = true