From edd41afedf6872baa8412b35bd23afec10ed26d8 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Thu, 31 Aug 2023 15:09:33 +0200 Subject: [PATCH] allow service users to get received shares Signed-off-by: jkoberg --- .../grpc/services/usershareprovider/usershareprovider.go | 6 +++--- pkg/share/manager/cs3/cs3.go | 2 +- pkg/share/manager/json/json.go | 2 +- pkg/share/manager/jsoncs3/jsoncs3.go | 2 +- pkg/share/manager/memory/memory.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/grpc/services/usershareprovider/usershareprovider.go b/internal/grpc/services/usershareprovider/usershareprovider.go index fdec41b1b2..b850b5f4df 100644 --- a/internal/grpc/services/usershareprovider/usershareprovider.go +++ b/internal/grpc/services/usershareprovider/usershareprovider.go @@ -301,9 +301,9 @@ func (s *service) UpdateReceivedShare(ctx context.Context, req *collaboration.Up }, nil } - var uid *userpb.UserId - _ = utils.ReadJSONFromOpaque(req.Opaque, "userid", uid) - share, err := s.sm.UpdateReceivedShare(ctx, req.Share, req.UpdateMask, uid) + var uid userpb.UserId + _ = utils.ReadJSONFromOpaque(req.Opaque, "userid", &uid) + share, err := s.sm.UpdateReceivedShare(ctx, req.Share, req.UpdateMask, &uid) if err != nil { return &collaboration.UpdateReceivedShareResponse{ Status: status.NewInternal(ctx, "error updating received share"), diff --git a/pkg/share/manager/cs3/cs3.go b/pkg/share/manager/cs3/cs3.go index 04bb9d20be..ed5d665c2e 100644 --- a/pkg/share/manager/cs3/cs3.go +++ b/pkg/share/manager/cs3/cs3.go @@ -343,7 +343,7 @@ func (m *Manager) GetShare(ctx context.Context, ref *collaboration.ShareReferenc // check if we are the owner or the grantee user := ctxpkg.ContextMustGetUser(ctx) - if share.IsCreatedByUser(s, user) || share.IsGrantedToUser(s, user) { + if user.GetId().GetType() == userpb.UserType_USER_TYPE_SERVICE || share.IsCreatedByUser(s, user) || share.IsGrantedToUser(s, user) { return s, nil } diff --git a/pkg/share/manager/json/json.go b/pkg/share/manager/json/json.go index 0d0b7b4982..7f78e226e7 100644 --- a/pkg/share/manager/json/json.go +++ b/pkg/share/manager/json/json.go @@ -542,7 +542,7 @@ func (m *mgr) getReceived(ctx context.Context, ref *collaboration.ShareReference return nil, err } user := ctxpkg.ContextMustGetUser(ctx) - if !share.IsGrantedToUser(s, user) { + if user.GetId().GetType() != userv1beta1.UserType_USER_TYPE_SERVICE && !share.IsGrantedToUser(s, user) { return nil, errtypes.NotFound(ref.String()) } return m.convert(user.Id, s), nil diff --git a/pkg/share/manager/jsoncs3/jsoncs3.go b/pkg/share/manager/jsoncs3/jsoncs3.go index 2fe7eb11e3..2bfeeb0b0d 100644 --- a/pkg/share/manager/jsoncs3/jsoncs3.go +++ b/pkg/share/manager/jsoncs3/jsoncs3.go @@ -955,7 +955,7 @@ func (m *Manager) getReceived(ctx context.Context, ref *collaboration.ShareRefer return nil, err } user := ctxpkg.ContextMustGetUser(ctx) - if !share.IsGrantedToUser(s, user) { + if user.GetId().GetType() != userv1beta1.UserType_USER_TYPE_SERVICE && !share.IsGrantedToUser(s, user) { return nil, errtypes.NotFound(ref.String()) } if share.IsExpired(s) { diff --git a/pkg/share/manager/memory/memory.go b/pkg/share/manager/memory/memory.go index ea5abd7955..2719320dbb 100644 --- a/pkg/share/manager/memory/memory.go +++ b/pkg/share/manager/memory/memory.go @@ -335,7 +335,7 @@ func (m *manager) getReceived(ctx context.Context, ref *collaboration.ShareRefer user := ctxpkg.ContextMustGetUser(ctx) for _, s := range m.shares { if sharesEqual(ref, s) { - if share.IsGrantedToUser(s, user) { + if user.GetId().GetType() == userv1beta1.UserType_USER_TYPE_SERVICE || share.IsGrantedToUser(s, user) { rs := m.convert(ctx, s) return rs, nil }