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

Space grants #2464

Merged
merged 2 commits into from
Jan 21, 2022
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
9 changes: 9 additions & 0 deletions changelog/unreleased/extract-space-grants.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Bugfix: pass spacegrants when adding member to space

When creating a space grant there should not be created a new space.
Unfortunately SpaceGrant didn't work when adding members to a space.
Now a value is placed in the ctx of the storageprovider on which decomposedfs reacts



https://github.com/cs3org/reva/pull/2464
9 changes: 9 additions & 0 deletions internal/grpc/services/storageprovider/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,15 @@ func (s *service) DenyGrant(ctx context.Context, req *provider.DenyGrantRequest)
}

func (s *service) AddGrant(ctx context.Context, req *provider.AddGrantRequest) (*provider.AddGrantResponse, error) {
// TODO: update CS3 APIs
if req.Opaque != nil {
_, spacegrant := req.Opaque.Map["spacegrant"]
if spacegrant {
ctx = context.WithValue(ctx, utils.SpaceGrant, struct{}{})
}

}

// check grantee type is valid
if req.Grant.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_INVALID {
return &provider.AddGrantResponse{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,16 @@ func (h *Handler) addSpaceMember(w http.ResponseWriter, r *http.Request, info *p
return
}

// TODO: change CS3 APIs
opaque := &types.Opaque{
Map: map[string]*types.OpaqueEntry{
"spacegrant": {},
},
}

addGrantRes, err := providerClient.AddGrant(ctx, &provider.AddGrantRequest{
Ref: ref,
Opaque: opaque,
Ref: ref,
Grant: &provider.Grant{
Grantee: &grantee,
Permissions: role.CS3ResourcePermissions(),
Expand Down
6 changes: 2 additions & 4 deletions pkg/storage/utils/decomposedfs/grants.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ import (
"github.com/cs3org/reva/pkg/storage/utils/ace"
"github.com/cs3org/reva/pkg/storage/utils/decomposedfs/node"
"github.com/cs3org/reva/pkg/storage/utils/decomposedfs/xattrs"
"github.com/cs3org/reva/pkg/utils"
"github.com/pkg/xattr"
)

// SpaceGrant is the key used to signal not to create a new space when a grant is assigned to a storage space.
var SpaceGrant struct{}

// DenyGrant denies access to a resource.
func (fs *Decomposedfs) DenyGrant(ctx context.Context, ref *provider.Reference, g *provider.Grantee) error {
return errtypes.NotSupported("decomposedfs: not supported")
Expand Down Expand Up @@ -72,7 +70,7 @@ func (fs *Decomposedfs) AddGrant(ctx context.Context, ref *provider.Reference, g
}

// when a grant is added to a space, do not add a new space under "shares"
if spaceGrant := ctx.Value(SpaceGrant); spaceGrant == nil {
if spaceGrant := ctx.Value(utils.SpaceGrant); spaceGrant == nil {
err := fs.createStorageSpace(ctx, "share", node.ID)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/spaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (fs *Decomposedfs) CreateStorageSpace(ctx context.Context, req *provider.Cr
},
}

ctx = context.WithValue(ctx, SpaceGrant, struct{}{})
ctx = context.WithValue(ctx, utils.SpaceGrant, struct{}{})

if err := fs.AddGrant(ctx, &provider.Reference{
ResourceId: resp.StorageSpace.Root,
Expand Down
3 changes: 3 additions & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ var (

// PublicStorageProviderID is the id used by the sharestorageprovider
PublicStorageProviderID = "7993447f-687f-490d-875c-ac95e89a62a4"

// SpaceGrant is used to signal the storageprovider that the grant is on a space
SpaceGrant struct{}
)

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