Skip to content

Commit bc20acb

Browse files
kobergjbutonic
authored andcommitted
Space grants (cs3org#2464)
* send spacegrants and pass them to decomposedfs Signed-off-by: jkoberg <[email protected]> * add changelog item Signed-off-by: jkoberg <[email protected]>
1 parent d07d63e commit bc20acb

File tree

6 files changed

+33
-6
lines changed

6 files changed

+33
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Bugfix: pass spacegrants when adding member to space
2+
3+
When creating a space grant there should not be created a new space.
4+
Unfortunately SpaceGrant didn't work when adding members to a space.
5+
Now a value is placed in the ctx of the storageprovider on which decomposedfs reacts
6+
7+
8+
9+
https://github.com/cs3org/reva/pull/2464

internal/grpc/services/storageprovider/storageprovider.go

+9
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,15 @@ func (s *service) DenyGrant(ctx context.Context, req *provider.DenyGrantRequest)
11281128
}
11291129

11301130
func (s *service) AddGrant(ctx context.Context, req *provider.AddGrantRequest) (*provider.AddGrantResponse, error) {
1131+
// TODO: update CS3 APIs
1132+
if req.Opaque != nil {
1133+
_, spacegrant := req.Opaque.Map["spacegrant"]
1134+
if spacegrant {
1135+
ctx = context.WithValue(ctx, utils.SpaceGrant, struct{}{})
1136+
}
1137+
1138+
}
1139+
11311140
// check grantee type is valid
11321141
if req.Grant.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_INVALID {
11331142
return &provider.AddGrantResponse{

internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/spaces.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,16 @@ func (h *Handler) addSpaceMember(w http.ResponseWriter, r *http.Request, info *p
102102
return
103103
}
104104

105+
// TODO: change CS3 APIs
106+
opaque := &types.Opaque{
107+
Map: map[string]*types.OpaqueEntry{
108+
"spacegrant": {},
109+
},
110+
}
111+
105112
addGrantRes, err := providerClient.AddGrant(ctx, &provider.AddGrantRequest{
106-
Ref: ref,
113+
Opaque: opaque,
114+
Ref: ref,
107115
Grant: &provider.Grant{
108116
Grantee: &grantee,
109117
Permissions: role.CS3ResourcePermissions(),

pkg/storage/utils/decomposedfs/grants.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ import (
2929
"github.com/cs3org/reva/pkg/storage/utils/ace"
3030
"github.com/cs3org/reva/pkg/storage/utils/decomposedfs/node"
3131
"github.com/cs3org/reva/pkg/storage/utils/decomposedfs/xattrs"
32+
"github.com/cs3org/reva/pkg/utils"
3233
"github.com/pkg/xattr"
3334
)
3435

35-
// SpaceGrant is the key used to signal not to create a new space when a grant is assigned to a storage space.
36-
var SpaceGrant struct{}
37-
3836
// DenyGrant denies access to a resource.
3937
func (fs *Decomposedfs) DenyGrant(ctx context.Context, ref *provider.Reference, g *provider.Grantee) error {
4038
return errtypes.NotSupported("decomposedfs: not supported")
@@ -71,7 +69,7 @@ func (fs *Decomposedfs) AddGrant(ctx context.Context, ref *provider.Reference, g
7169
}
7270

7371
// when a grant is added to a space, do not add a new space under "shares"
74-
if spaceGrant := ctx.Value(SpaceGrant); spaceGrant == nil {
72+
if spaceGrant := ctx.Value(utils.SpaceGrant); spaceGrant == nil {
7573
err := fs.createStorageSpace(ctx, "share", node.ID)
7674
if err != nil {
7775
return err

pkg/storage/utils/decomposedfs/spaces.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr
143143
},
144144
}
145145

146-
ctx = context.WithValue(ctx, SpaceGrant, struct{}{})
146+
ctx = context.WithValue(ctx, utils.SpaceGrant, struct{}{})
147147

148148
if err := fs.AddGrant(ctx, &provider.Reference{
149149
ResourceId: resp.StorageSpace.Root,

pkg/utils/utils.go

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ var (
5555

5656
// PublicStorageProviderID is the id used by the sharestorageprovider
5757
PublicStorageProviderID = "7993447f-687f-490d-875c-ac95e89a62a4"
58+
59+
// SpaceGrant is used to signal the storageprovider that the grant is on a space
60+
SpaceGrant struct{}
5861
)
5962

6063
// Skip evaluates whether a source endpoint contains any of the prefixes.

0 commit comments

Comments
 (0)