Skip to content

Commit 19df2c4

Browse files
committed
Fix the OCM role file editor
1 parent d137cb7 commit 19df2c4

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Bugfix: Fix the OCM role file editor
2+
3+
Fix the OCM role file editor permission set. The redundant permissions have been removed.
4+
5+
https://github.com/cs3org/reva/pull/5108
6+
https://github.com/owncloud/ocis/issues/11054

internal/http/services/ocmd/notifications.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,11 @@ func (h *notifHandler) handleShareChangePermission(ctx context.Context, req *not
174174

175175
o := &typesv1beta1.Opaque{}
176176
utils.AppendPlainToOpaque(o, "grantee", req.Notification.Grantee)
177+
utils.AppendPlainToOpaque(o, "resourceType", req.ResourceType)
177178

178179
res, err := gatewayClient.UpdateOCMCoreShare(ctx, &ocmcore.UpdateOCMCoreShareRequest{
179180
OcmShareId: req.ProviderId,
180-
Protocols: getProtocols(req.Notification.Protocols),
181+
Protocols: getProtocols(req.Notification.Protocols, o),
181182
Opaque: o,
182183
})
183184
if err != nil {

internal/http/services/ocmd/protocols.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
ocm "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1"
2929
providerv1beta1 "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
30+
typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
3031
ocmshare "github.com/cs3org/reva/v2/pkg/ocm/share"
3132
utils "github.com/cs3org/reva/v2/pkg/utils"
3233
)
@@ -38,7 +39,7 @@ type Protocols []Protocol
3839
// in the OCM share.
3940
type Protocol interface {
4041
// ToOCMProtocol convert the protocol to a ocm Protocol struct
41-
ToOCMProtocol() *ocm.Protocol
42+
ToOCMProtocol(*typesv1beta1.Opaque) *ocm.Protocol
4243
}
4344

4445
// protocols supported by the OCM API
@@ -51,7 +52,8 @@ type WebDAV struct {
5152
}
5253

5354
// ToOCMProtocol convert the protocol to a ocm Protocol struct.
54-
func (w *WebDAV) ToOCMProtocol() *ocm.Protocol {
55+
func (w *WebDAV) ToOCMProtocol(o *typesv1beta1.Opaque) *ocm.Protocol {
56+
resourceType := utils.ReadPlainFromOpaque(o, "resourceType")
5557
perms := &ocm.SharePermissions{
5658
Permissions: &providerv1beta1.ResourcePermissions{},
5759
}
@@ -67,9 +69,11 @@ func (w *WebDAV) ToOCMProtocol() *ocm.Protocol {
6769
case "write":
6870
perms.Permissions.InitiateFileUpload = true
6971
perms.Permissions.RestoreRecycleItem = true
70-
perms.Permissions.CreateContainer = true
71-
perms.Permissions.Delete = true
72-
perms.Permissions.Move = true
72+
if resourceType == "folder" {
73+
perms.Permissions.Move = true
74+
perms.Permissions.CreateContainer = true
75+
perms.Permissions.Delete = true
76+
}
7377
}
7478
}
7579

@@ -83,7 +87,7 @@ type Webapp struct {
8387
}
8488

8589
// ToOCMProtocol convert the protocol to a ocm Protocol struct.
86-
func (w *Webapp) ToOCMProtocol() *ocm.Protocol {
90+
func (w *Webapp) ToOCMProtocol(_ *typesv1beta1.Opaque) *ocm.Protocol {
8791
return ocmshare.NewWebappProtocol(w.URITemplate, utils.GetAppViewMode(w.ViewMode))
8892
}
8993

@@ -95,7 +99,7 @@ type Datatx struct {
9599
}
96100

97101
// ToOCMProtocol convert the protocol to a ocm Protocol struct.
98-
func (w *Datatx) ToOCMProtocol() *ocm.Protocol {
102+
func (w *Datatx) ToOCMProtocol(_ *typesv1beta1.Opaque) *ocm.Protocol {
99103
return ocmshare.NewTransferProtocol(w.SourceURI, w.SharedSecret, w.Size)
100104
}
101105

internal/http/services/ocmd/shares.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ func (h *sharesHandler) CreateShare(w http.ResponseWriter, r *http.Request) {
154154
return
155155
}
156156

157+
o := &types.Opaque{}
158+
utils.AppendPlainToOpaque(o, "resourceType", req.ResourceType)
159+
157160
createShareReq := &ocmcore.CreateOCMCoreShareRequest{
158161
Description: req.Description,
159162
Name: req.Name,
@@ -163,7 +166,7 @@ func (h *sharesHandler) CreateShare(w http.ResponseWriter, r *http.Request) {
163166
ShareWith: userRes.User.Id,
164167
ResourceType: getResourceTypeFromOCMRequest(req.ResourceType),
165168
ShareType: getOCMShareType(req.ShareType),
166-
Protocols: getProtocols(req.Protocols),
169+
Protocols: getProtocols(req.Protocols, o),
167170
}
168171

169172
if req.Expiration != 0 {
@@ -251,10 +254,10 @@ func getOCMShareType(t string) ocm.ShareType {
251254
return ocm.ShareType_SHARE_TYPE_GROUP
252255
}
253256

254-
func getProtocols(p Protocols) []*ocm.Protocol {
257+
func getProtocols(p Protocols, o *types.Opaque) []*ocm.Protocol {
255258
prot := make([]*ocm.Protocol, 0, len(p))
256259
for _, data := range p {
257-
prot = append(prot, data.ToOCMProtocol())
260+
prot = append(prot, data.ToOCMProtocol(o))
258261
}
259262
return prot
260263
}

0 commit comments

Comments
 (0)