Skip to content

Commit

Permalink
non personal spaces need virtual owner
Browse files Browse the repository at this point in the history
  • Loading branch information
micbar committed Jul 22, 2022
1 parent ec605be commit d38592a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog/unreleased/space-owner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Project spaces need no real owner

Make it possible to use a non existing user as a space owner.

https://github.com/cs3org/reva/pull/3091
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,14 @@ func (h *Handler) mustGetIdentifiers(ctx context.Context, client gateway.Gateway
return &userIdentifiers{}
}

if id == utils.VirtualSpaceOwner.Id.GetOpaqueId() {
return &userIdentifiers{
DisplayName: utils.VirtualSpaceOwner.DisplayName,
Username: utils.VirtualSpaceOwner.Username,
Mail: utils.VirtualSpaceOwner.Mail,
}
}

if idIf, err := h.userIdentifierCache.Get(id); err == nil {
sublog.Debug().Msg("cache hit")
return idIf.(*userIdentifiers)
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/grants.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (fs *Decomposedfs) AddGrant(ctx context.Context, ref *provider.Reference, g
// When the owner is empty but grants are set then we do want to check the grants.
// However, if we are trying to edit an existing grant we do not have to check for permission if the user owns the grant
// TODO: find a better to check this
if !(len(grants) == 0 && (owner == nil || owner.OpaqueId == "")) {
if !(len(grants) == 0 && (owner == nil || owner.OpaqueId == utils.VirtualSpaceOwner.Id.GetOpaqueId())) {
ok, err := fs.p.HasPermission(ctx, node, func(rp *provider.ResourcePermissions) bool {
return rp.AddGrant
})
Expand Down
2 changes: 2 additions & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ var (
PublicStorageProviderID = "7993447f-687f-490d-875c-ac95e89a62a4"
// PublicStorageSpaceID is the space id used by the sharestorageprovider
PublicStorageSpaceID = "7993447f-687f-490d-875c-ac95e89a62a4"
// VirtualSpaceOwner is the non-existing user which is needed for public share impersonation
VirtualSpaceOwner = userpb.User{Id: &userpb.UserId{OpaqueId: "dbdf733d-427f-4ac3-8093-2cba5c307e4c", Type: userpb.UserType_USER_TYPE_INVALID}, DisplayName: "Virtual Space Owner", Username: "virtualowner"}

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

0 comments on commit d38592a

Please sign in to comment.