From b2f1e849fd23b3a3f9b1a19ab0de2ec98df9ff69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Fri, 7 Jul 2023 10:46:53 +0200 Subject: [PATCH 1/3] Use the owner auth to get the path of shared resources This fixes searching received shares that were not shared from the space root. --- services/search/pkg/search/service.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/search/pkg/search/service.go b/services/search/pkg/search/service.go index fd39dea05f..2c7f4ce842 100644 --- a/services/search/pkg/search/service.go +++ b/services/search/pkg/search/service.go @@ -246,7 +246,12 @@ func (s *Service) searchIndex(ctx context.Context, req *searchsvc.SearchRequest, return nil, err } - gpRes, err := gatewayClient.GetPath(ctx, &provider.GetPathRequest{ + ownerCtx, err := getAuthContext(&user.User{Id: space.Owner.Id}, s.gatewaySelector, s.secret, s.logger) + if err != nil { + return nil, err + } + + gpRes, err := gatewayClient.GetPath(ownerCtx, &provider.GetPathRequest{ ResourceId: space.Root, }) if err != nil { From 4c53320c1f34f4a4e4774a0746dc6b4d3ff2da57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Fri, 7 Jul 2023 11:17:46 +0200 Subject: [PATCH 2/3] Add changelog --- changelog/unreleased/fix-searching-shares.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/unreleased/fix-searching-shares.md diff --git a/changelog/unreleased/fix-searching-shares.md b/changelog/unreleased/fix-searching-shares.md new file mode 100644 index 0000000000..19587c7418 --- /dev/null +++ b/changelog/unreleased/fix-searching-shares.md @@ -0,0 +1,5 @@ +Bugfix: Fix search shares + +We fixed a problem where searching shares did not yield results when the resource was not shared from the space root. + +https://github.com/owncloud/ocis/pull/6741 From ec8a2601193d36c84d49aed1832e40e0daf674b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Duffeck?= Date: Fri, 7 Jul 2023 12:48:00 +0200 Subject: [PATCH 3/3] Handle shares received from project spaces. Unfortunately searching these kinds of shares can't be fully fixed until the service accounts have been implemented. --- services/search/pkg/search/service.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/services/search/pkg/search/service.go b/services/search/pkg/search/service.go index 2c7f4ce842..f7ae9ca5dc 100644 --- a/services/search/pkg/search/service.go +++ b/services/search/pkg/search/service.go @@ -246,9 +246,18 @@ func (s *Service) searchIndex(ctx context.Context, req *searchsvc.SearchRequest, return nil, err } - ownerCtx, err := getAuthContext(&user.User{Id: space.Owner.Id}, s.gatewaySelector, s.secret, s.logger) - if err != nil { - return nil, err + var ownerCtx context.Context + if space.Owner.Id.Type == user.UserType_USER_TYPE_SPACE_OWNER { + // We can't impersonate SPACE_OWNER users and have to fall back to using the user auth instead, + // which will not resolve the absolute path of the share in the space but only the part the user + // is allowed to see. + // In the future this problem can be solved using service accounts. + ownerCtx = ctx + } else { + ownerCtx, err = getAuthContext(&user.User{Id: space.Owner.Id}, s.gatewaySelector, s.secret, s.logger) + if err != nil { + return nil, err + } } gpRes, err := gatewayClient.GetPath(ownerCtx, &provider.GetPathRequest{