Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(federation): re-add RequestSharedSecret job if necessary
fighting another race condition with federated server setup

Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz authored and AndyScherzinger committed Sep 3, 2024
commit 1ba58415e6bcc5f6b93e9a03de3db607fbedf950
20 changes: 20 additions & 0 deletions apps/federation/lib/Controller/OCSAuthAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
namespace OCA\Federation\Controller;

use OCA\Federation\BackgroundJob\RequestSharedSecret;
use OCA\Federation\DbHandler;
use OCA\Federation\TrustedServers;
use OCP\AppFramework\Http;
Expand Down Expand Up @@ -126,6 +127,25 @@ public function requestSharedSecret(string $url, string $token): DataResponse {
'remote server (' . $url . ') presented lower token. We will initiate the exchange of the shared secret.',
['app' => 'federation']
);

$hasJob = false;
foreach ($this->jobList->getJobsIterator(RequestSharedSecret::class, null, 0) as $job) {
$arg = $job->getArgument();
if (is_array($arg) && isset($arg['url']) && $arg['url'] === $url) {
$hasJob = true;
break;
}
}
if (!$hasJob) {
$this->jobList->add(
RequestSharedSecret::class,
[
'url' => $url,
'token' => $this->dbHandler->getToken($url),
'created' => $this->timeFactory->getTime()
]
);
}
throw new OCSForbiddenException();
}

Expand Down