Merge pull request #6741 from aduffeck/fix-searching-deep-shares

Use the owner auth to get the path of shared resources
This commit is contained in:
Roman Perekhod authored and GitHub committed 2023-07-07 15:04:57 +03:00
commit a169609a2b
2 files changed
+20 -1

No files matched your search

@@ -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
+15 -1
View File
@@ -246,7 +246,21 @@ func (s *Service) searchIndex(ctx context.Context, req *searchsvc.SearchRequest,
return nil, err
}
gpRes, err := gatewayClient.GetPath(ctx, &provider.GetPathRequest{
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{
ResourceId: space.Root,
})
if err != nil {