fix(signed-request): use share owner on reshare

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/49646/head
Maxence Lange 2024-12-05 19:57:10 +07:00
parent ac470184e7
commit abd24f9bef
2 changed files with 9 additions and 3 deletions

@ -441,7 +441,7 @@ class RequestHandlerController extends Controller {
return;
}
} elseif ($instance !== $signedRequest->getOrigin()) {
throw new IncomingRequestException('remote instance {instance} not linked to origin {origin}', ['instance' => $instance, 'origin' => $signedRequest->getOrigin()]);
throw new IncomingRequestException('remote instance ' . $instance . ' not linked to origin ' . $signedRequest->getOrigin());
}
}

@ -766,10 +766,16 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider {
$provider = $this->shareProviderFactory->getProviderForType(IShare::TYPE_REMOTE);
try {
$share = $provider->getShareByToken($sharedSecret);
} catch (ShareNotFound $e) {
} catch (ShareNotFound) {
return '';
}
return $share->getSharedWith();
// if uid_owner is a local account, the request comes from the recipient
// if not, request comes from the instance that owns the share and recipient is the re-sharer
if ($this->userManager->get($share->getShareOwner()) !== null) {
return $share->getSharedWith();
} else {
return $share->getShareOwner();
}
}
}