Skip to content

Commit

Permalink
allow service users to get received shares
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj committed Sep 1, 2023
1 parent bce2d6f commit edd41af
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions internal/grpc/services/usershareprovider/usershareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
2 changes: 1 addition & 1 deletion pkg/share/manager/cs3/cs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/share/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/share/manager/jsoncs3/jsoncs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/share/manager/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit edd41af

Please sign in to comment.