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: remove grant from storage when removing OCM share #4989

Merged
merged 2 commits into from
Dec 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
7 changes: 7 additions & 0 deletions changelog/unreleased/fix_ocm_removegrant.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Deleting OCM share also updates storageprovider

When remvoving an OCM share we're now also removing the related grant from
the storage provider.

https://github.com/cs3org/reva/pull/4989
https://github.com/owncloud/ocis/issues/10262
26 changes: 26 additions & 0 deletions internal/grpc/services/gateway/ocmshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,37 @@ func (s *svc) RemoveOCMShare(ctx context.Context, req *ocm.RemoveOCMShareRequest
}, nil
}

getShareRes, err := c.GetOCMShare(ctx, &ocm.GetOCMShareRequest{
Ref: req.Ref,
})
if err != nil {
return nil, errors.Wrap(err, "gateway: error calling GetOCMShare")
}
if getShareRes.Status.Code != rpc.Code_CODE_OK {
res := &ocm.RemoveOCMShareResponse{
Status: status.NewInternal(ctx,
"error getting ocm share when committing to the storage"),
}
return res, nil
}
share := getShareRes.Share

res, err := c.RemoveOCMShare(ctx, req)
if err != nil {
return nil, errors.Wrap(err, "gateway: error calling RemoveOCMShare")
}

// remove the grant from the storage provider
status, err := s.removeGrant(ctx, share.GetResourceId(), share.GetGrantee(), share.GetAccessMethods()[0].GetWebdavOptions().GetPermissions(), nil)
if err != nil {
return nil, errors.Wrap(err, "gateway: error removing grant from storage")
}
if status.Code != rpc.Code_CODE_OK {
return &ocm.RemoveOCMShareResponse{
Status: status,
}, err
}

return res, nil
}

Expand Down
4 changes: 0 additions & 4 deletions pkg/storage/utils/ace/ace.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ func FromGrant(g *provider.Grant) *ACE {
}

func UserAce(id *userpb.UserId) string {
if id.GetType() == userpb.UserType_USER_TYPE_FEDERATED {
return "u:" + id.OpaqueId + "@" + id.Idp
}

return "u:" + id.OpaqueId
}

Expand Down
Loading