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 ocm share updates #9980

Merged
merged 9 commits into from
Sep 11, 2024
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
6 changes: 6 additions & 0 deletions changelog/unreleased/allow-update-ocm-shares.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Allow update of ocm shares

We fixed a bug that prevented ocm shares to be updated or removed.

https://github.com/owncloud/ocis/pull/9980
https://github.com/owncloud/ocis/issues/9926
2 changes: 2 additions & 0 deletions changelog/unreleased/bump-reva.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Enhancement: Bump reva

Bumps reva version

https://github.com/owncloud/ocis/pull/9980
https://github.com/owncloud/ocis/pull/9981
https://github.com/owncloud/ocis/pull/9981
https://github.com/owncloud/ocis/pull/9920
https://github.com/owncloud/ocis/pull/9879
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/coreos/go-oidc/v3 v3.11.0
github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb
github.com/cs3org/reva/v2 v2.23.1-0.20240905133054-2de6ff31c4e3
github.com/cs3org/reva/v2 v2.24.1-0.20240911132317-de8cea1f9e72
github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25
github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e
github.com/egirna/icap-client v0.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c=
github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME=
github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb h1:KmYZDReplv/yfwc1LNYpDcVhVujC3Pasv6WjXx1haSU=
github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb/go.mod h1:yyP8PRo0EZou3nSH7H4qjlzQwaydPeIRNgX50npQHpE=
github.com/cs3org/reva/v2 v2.23.1-0.20240905133054-2de6ff31c4e3 h1:L1fD7ShX6W17e5YMgWpcmCq2KVHQy48gFrnc261iohQ=
github.com/cs3org/reva/v2 v2.23.1-0.20240905133054-2de6ff31c4e3/go.mod h1:p7CHBXcg6sSqB+0JMNDfC1S7TSh9FghXkw1kTV3KcJI=
github.com/cs3org/reva/v2 v2.24.1-0.20240911132317-de8cea1f9e72 h1:J1CCIbBOKVGEqEng3OwZzeX5jVLb8iTzM251D2C8oyo=
github.com/cs3org/reva/v2 v2.24.1-0.20240911132317-de8cea1f9e72/go.mod h1:p7CHBXcg6sSqB+0JMNDfC1S7TSh9FghXkw1kTV3KcJI=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg=
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
Expand Down
46 changes: 37 additions & 9 deletions services/graph/pkg/service/v0/api_driveitem_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ import (
ocm "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1"
storageprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/go-chi/chi/v5"
"github.com/go-chi/render"
libregraph "github.com/owncloud/libre-graph-api-go"

revactx "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/publicshare"
"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/v2/pkg/share"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/go-chi/chi/v5"
"github.com/go-chi/render"
libregraph "github.com/owncloud/libre-graph-api-go"

"github.com/owncloud/ocis/v2/ocis-pkg/l10n"
l10n_pkg "github.com/owncloud/ocis/v2/services/graph/pkg/l10n"
Expand Down Expand Up @@ -71,6 +72,7 @@ const (
Public
User
Space
OCM
)

// NewDriveItemPermissionsService creates a new DriveItemPermissionsService
Expand Down Expand Up @@ -463,6 +465,13 @@ func (s DriveItemPermissionsService) DeletePermission(ctx context.Context, itemI
}
}

if sharedResourceID == nil && s.config.IncludeOCMSharees {
sharedResourceID, err = s.getOCMPermissionResourceID(ctx, permissionID)
if err == nil {
permissionType = OCM
}
}

switch {
case err != nil:
return err
Expand All @@ -486,10 +495,12 @@ func (s DriveItemPermissionsService) DeletePermission(ctx context.Context, itemI
return s.removePublicShare(ctx, permissionID)
case Space:
return s.removeSpacePermission(ctx, permissionID, sharedResourceID)
case OCM:
return s.removeOCMPermission(ctx, permissionID)
default:
// This should never be reached
return errorcode.New(errorcode.GeneralException, "failed to delete permission")
}

// This should never be reached
return errorcode.New(errorcode.GeneralException, "failed to delete permission")
}

// DeleteSpaceRootPermission deletes a permission on the root item of a project space
Expand All @@ -515,6 +526,13 @@ func (s DriveItemPermissionsService) DeleteSpaceRootPermission(ctx context.Conte
// UpdatePermission updates a permission on a drive item
func (s DriveItemPermissionsService) UpdatePermission(ctx context.Context, itemID *storageprovider.ResourceId, permissionID string, newPermission libregraph.Permission) (libregraph.Permission, error) {
oldPermission, sharedResourceID, err := s.getPermissionByID(ctx, permissionID, itemID)

// try to get the permission from ocm if the permission was not found first place
if err != nil && s.config.IncludeOCMSharees {
oldPermission, sharedResourceID, err = s.getOCMPermissionByID(ctx, permissionID, itemID)
}

// if we still can't find the permission, return an error
if err != nil {
return libregraph.Permission{}, err
}
Expand All @@ -537,10 +555,20 @@ func (s DriveItemPermissionsService) UpdatePermission(ctx context.Context, itemI

// This is a user share
updatedPermission, err := s.updateUserShare(ctx, permissionID, sharedResourceID, &newPermission)
if err != nil {
return libregraph.Permission{}, err
if err == nil && updatedPermission != nil {
return *updatedPermission, nil
}
return *updatedPermission, nil

// This is an ocm share
if s.config.IncludeOCMSharees {
updatePermission, err := s.updateOCMPermission(ctx, permissionID, itemID, &newPermission)
if err == nil {
return *updatePermission, nil
}
}

return libregraph.Permission{}, err

}

// UpdateSpaceRootPermission updates a permission on the root item of a project space
Expand Down
Loading