Skip to content

Commit 1ba5841

Browse files
blizzzAndyScherzinger
authored andcommitted
fix(federation): re-add RequestSharedSecret job if necessary
fighting another race condition with federated server setup Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent 6b85a3a commit 1ba5841

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

apps/federation/lib/Controller/OCSAuthAPIController.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
namespace OCA\Federation\Controller;
99

10+
use OCA\Federation\BackgroundJob\RequestSharedSecret;
1011
use OCA\Federation\DbHandler;
1112
use OCA\Federation\TrustedServers;
1213
use OCP\AppFramework\Http;
@@ -126,6 +127,25 @@ public function requestSharedSecret(string $url, string $token): DataResponse {
126127
'remote server (' . $url . ') presented lower token. We will initiate the exchange of the shared secret.',
127128
['app' => 'federation']
128129
);
130+
131+
$hasJob = false;
132+
foreach ($this->jobList->getJobsIterator(RequestSharedSecret::class, null, 0) as $job) {
133+
$arg = $job->getArgument();
134+
if (is_array($arg) && isset($arg['url']) && $arg['url'] === $url) {
135+
$hasJob = true;
136+
break;
137+
}
138+
}
139+
if (!$hasJob) {
140+
$this->jobList->add(
141+
RequestSharedSecret::class,
142+
[
143+
'url' => $url,
144+
'token' => $this->dbHandler->getToken($url),
145+
'created' => $this->timeFactory->getTime()
146+
]
147+
);
148+
}
129149
throw new OCSForbiddenException();
130150
}
131151

0 commit comments

Comments
 (0)