diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2024-04-16 13:14:11 +0200 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2024-09-03 12:21:58 +0200 |
commit | 1ba58415e6bcc5f6b93e9a03de3db607fbedf950 (patch) | |
tree | 3356f0c1a783a7960db06be5ee341c67e0a63f31 | |
parent | 6b85a3ae0eec4f6516459d223159a8d8e301e445 (diff) | |
download | nextcloud-server-fix/noid/federation-really-surely-init-token.tar.gz nextcloud-server-fix/noid/federation-really-surely-init-token.zip |
fix(federation): re-add RequestSharedSecret job if necessaryfix/noid/federation-really-surely-init-token
fighting another race condition with federated server setup
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
-rw-r--r-- | apps/federation/lib/Controller/OCSAuthAPIController.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/apps/federation/lib/Controller/OCSAuthAPIController.php b/apps/federation/lib/Controller/OCSAuthAPIController.php index 8412868da42..0daf34d7dd5 100644 --- a/apps/federation/lib/Controller/OCSAuthAPIController.php +++ b/apps/federation/lib/Controller/OCSAuthAPIController.php @@ -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; @@ -126,6 +127,25 @@ class OCSAuthAPIController extends OCSController { '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(); } |